From a70c934e258ac4c47425b207bf80a309eed81d72 Mon Sep 17 00:00:00 2001 From: Poloskun_ Date: Sat, 17 Feb 2024 21:40:28 +0300 Subject: [PATCH] Small update - Added new poopies to .editorconfig - Updated StatusAPI - Updated ResourceAPI - Updated TranslationAPI - Some other bug improvements --- .editorconfig | 255 ++++ .../java/com/minersstudios/mscore/MSCore.java | 57 +- .../command/impl/ReloadConfigCommand.java | 4 +- .../inventory/plugin/InventoryHolder.java | 6 +- .../recipe/builder/RecipeBuilder.java | 56 +- .../inventory/recipe/choice/CustomChoice.java | 142 ++- .../recipe/entry/BuilderRecipeEntry.java | 3 - .../inventory/recipe/entry/RecipeEntry.java | 79 +- .../recipe/entry/RecipeEntryImpl.java | 12 +- .../recipe/entry/SimpleRecipeEntry.java | 2 +- .../mscore/language/LanguageFile.java | 302 ----- .../mscore/language/LanguageRegistry.java | 1130 ----------------- .../listener/api/event/EventListener.java | 6 +- .../listener/api/packet/PacketListener.java | 8 +- .../event/server/ServerCommandListener.java | 4 +- .../mscore/locale/LanguageFile.java | 497 ++++++++ .../mscore/locale/Translation.java | 462 +++++++ .../mscore/locale/TranslationRegistry.java | 520 ++++++++ .../locale/TranslationRegistryImpl.java | 312 +++++ .../mscore/locale/Translations.java | 386 ++++++ .../FileTranslationResourceManager.java | 13 + .../GitHubTranslationResourceManager.java | 40 + .../resource/TranslationResourceManager.java | 107 ++ .../URITranslationResourceManager.java | 13 + .../mscore/plugin/GlobalConfig.java | 190 ++- .../minersstudios/mscore/plugin/MSLogger.java | 12 +- .../minersstudios/mscore/plugin/MSPlugin.java | 104 +- .../mscore/plugin/cache/MSCache.java | 22 +- .../mscore/plugin/cache/PluginCache.java | 20 +- .../mscore/plugin/status/FailureStatus.java | 60 - .../plugin/status/ImplPluginStatus.java | 66 - .../mscore/plugin/status/PluginStatus.java | 97 -- .../mscore/plugin/status/SuccessStatus.java | 142 --- .../mscore/resource/ResourceManager.java | 24 + .../file/AbstractFileResourceManager.java | 30 + .../resource/file/FileResourceManager.java | 16 + .../github/AbstractGithubResourceManager.java | 217 ++++ .../github/GithubResourceManager.java | 107 ++ .../resource/github}/Tag.java | 2 +- .../uri/AbstractURIResourceManager.java | 31 + .../resource/uri/URIResourceManager.java | 17 + .../mscore/status/FailureStatus.java | 50 + .../mscore/status/ImplStatus.java | 96 ++ .../minersstudios/mscore/status/Status.java | 291 +++++ .../{plugin => }/status/StatusHandler.java | 167 +-- .../mscore/status/StatusKey.java | 73 ++ .../{plugin => }/status/StatusWatcher.java | 571 ++++++--- .../mscore/status/SuccessStatus.java | 81 ++ .../mscore/status/package-info.java | 10 + .../mscore/utility/DateUtils.java | 4 +- .../mscore/utility/SharedConstants.java | 9 +- .../com/minersstudios/mscustoms/Config.java | 94 +- .../minersstudios/mscustoms/MSCustoms.java | 32 +- .../mscustoms/command/block/GiveCommand.java | 17 +- .../command/block/ReloadCommand.java | 4 +- .../mscustoms/command/decor/GiveCommand.java | 12 +- .../mscustoms/command/item/GiveCommand.java | 12 +- .../mscustoms/command/item/ReloadCommand.java | 4 +- .../custom/block/CustomBlockRegistry.java | 2 +- .../file/adapter/RecipeChoiceAdapter.java | 3 +- .../file/adapter/RecipeEntryAdapter.java | 2 +- .../custom/decor/CustomDecorDataImpl.java | 2 +- .../custom/decor/CustomDecorType.java | 6 +- .../mscustoms/custom/item/CustomItemType.java | 6 +- .../mscustoms/menu/CraftsMenu.java | 12 +- .../mscustoms/menu/RenamesMenu.java | 12 +- .../decor/christmas/ChristmasBall.java | 4 +- .../decor/christmas/ChristmasTallBall.java | 4 +- .../registry/decor/christmas/SantaSock.java | 4 +- .../decor/christmas/SnowflakeOnString.java | 4 +- .../registry/decor/christmas/Snowman.java | 4 +- .../registry/decor/christmas/SnowmanBall.java | 4 +- .../decor/christmas/StarOnString.java | 4 +- .../registry/decor/christmas/TreeStar.java | 4 +- .../registry/decor/decoration/home/Cell.java | 4 +- .../decor/decoration/home/CookingPot.java | 4 +- .../decor/decoration/home/OldCamera.java | 4 +- .../decor/decoration/home/Patefon.java | 4 +- .../decor/decoration/home/Piggybank.java | 4 +- .../decor/decoration/home/SmallClock.java | 4 +- .../decor/decoration/home/SmallGlobe.java | 4 +- .../decor/decoration/home/Whocintosh.java | 4 +- .../decor/decoration/home/head/DeerHead.java | 4 +- .../decoration/home/head/HoglinHead.java | 4 +- .../decoration/home/head/ZoglinHead.java | 4 +- .../decor/decoration/home/plush/BMOPlush.java | 4 +- .../decoration/home/plush/BrownBearPlush.java | 4 +- .../decoration/home/plush/RacoonPlush.java | 4 +- .../decoration/home/plush/WhocintoshMini.java | 4 +- .../decor/decoration/street/Brazier.java | 4 +- .../decor/decoration/street/FireHydrant.java | 4 +- .../decor/decoration/street/IronTrashcan.java | 4 +- .../decor/decoration/street/Wheelbarrow.java | 4 +- .../registry/decor/furniture/Nightstand.java | 4 +- .../decor/furniture/chair/Armchair.java | 4 +- .../decor/furniture/chair/BarStool.java | 4 +- .../registry/decor/furniture/chair/Chair.java | 4 +- .../decor/furniture/chair/CoolArmchair.java | 4 +- .../decor/furniture/chair/CoolChair.java | 4 +- .../chair/PaintableRockingChair.java | 4 +- .../decor/furniture/chair/RockingChair.java | 4 +- .../decor/furniture/chair/SmallArmchair.java | 4 +- .../decor/furniture/chair/SmallChair.java | 4 +- .../decor/furniture/lamp/BigLamp.java | 4 +- .../decor/furniture/lamp/SmallLamp.java | 4 +- .../decor/furniture/table/BigTable.java | 4 +- .../decor/furniture/table/SmallTable.java | 4 +- .../registry/item/AntiRadiationTextile.java | 4 +- .../mscustoms/registry/item/Cocaine.java | 4 +- .../mscustoms/registry/item/Dosimeter.java | 4 +- .../mscustoms/registry/item/PlumbumIngot.java | 16 +- .../mscustoms/registry/item/RawPlumbum.java | 10 +- .../mscustoms/registry/item/Wrench.java | 4 +- .../item/armor/hazmat/HazmatBoots.java | 4 +- .../item/armor/hazmat/HazmatChestplate.java | 4 +- .../item/armor/hazmat/HazmatHelmet.java | 4 +- .../item/armor/hazmat/HazmatLeggings.java | 4 +- .../registry/item/cards/CardsBicycle.java | 16 +- .../registry/item/cosmetics/LeatherHat.java | 4 +- .../minersstudios/mscustoms/sound/Sound.java | 83 +- .../mscustoms/sound/SoundAdapter.java | 35 +- .../mscustoms/sound/SoundGroup.java | 9 +- .../minersstudios/msessentials/Config.java | 228 ++-- .../msessentials/MSEssentials.java | 39 +- .../command/api/discord/SlashCommand.java | 6 +- .../discord/interaction/CommandHandler.java | 6 +- .../command/impl/discord/AddSkinCommand.java | 35 +- .../command/impl/discord/EditSkinCommand.java | 31 +- .../impl/discord/RemoveSkinCommand.java | 25 +- .../command/impl/discord/SkinListCommand.java | 13 +- .../command/impl/discord/UnlinkCommand.java | 20 +- .../admin/GetMapLocationCommand.java | 11 +- .../impl/minecraft/admin/KickCommand.java | 17 +- .../impl/minecraft/admin/SetServerSpawn.java | 22 +- .../minecraft/admin/WhitelistCommand.java | 20 +- .../impl/minecraft/admin/ban/BanCommand.java | 10 +- .../minecraft/admin/ban/UnBanCommand.java | 5 +- .../admin/msessentials/ReloadCommand.java | 4 +- .../admin/msessentials/UpdateIdsCommand.java | 4 +- .../msessentials/UpdateMutesCommand.java | 4 +- .../minecraft/admin/mute/MuteCommand.java | 12 +- .../minecraft/admin/mute/UnMuteCommand.java | 5 +- .../admin/player/AdminBanInfoCommand.java | 28 +- .../admin/player/AdminFirstJoinCommand.java | 4 +- .../admin/player/AdminGameParamsCommand.java | 40 +- .../admin/player/AdminMuteInfoCommand.java | 20 +- .../admin/player/AdminNameCommand.java | 25 +- .../player/AdminPlayerCommandHandler.java | 9 +- .../admin/player/AdminPronounsCommand.java | 12 +- .../admin/player/AdminSettingsCommand.java | 53 +- .../admin/player/AdminUpdateCommand.java | 4 +- .../TeleportToLastDeathLocationCommand.java | 10 +- .../admin/teleport/WorldTeleportCommand.java | 16 +- .../impl/minecraft/player/DiscordCommand.java | 19 +- .../player/PrivateMessageCommand.java | 11 +- .../minecraft/player/roleplay/DoCommand.java | 5 +- .../player/roleplay/FartCommand.java | 5 +- .../minecraft/player/roleplay/ItCommand.java | 5 +- .../minecraft/player/roleplay/MeCommand.java | 5 +- .../minecraft/player/roleplay/SitCommand.java | 8 +- .../player/roleplay/SpitCommand.java | 7 +- .../player/roleplay/TodoCommand.java | 5 +- .../minecraft/player/roleplay/TryCommand.java | 10 +- .../msessentials/discord/BotHandler.java | 168 ++- .../msessentials/discord/DiscordManager.java | 24 +- .../api/discord/AbstractDiscordListener.java | 2 +- .../listener/api/discord/DiscordListener.java | 6 +- .../impl/event/chat/AsyncChatListener.java | 9 +- .../event/command/UnknownCommandListener.java | 5 +- .../inventory/InventoryClickListener.java | 4 +- .../player/AsyncPlayerPreLoginListener.java | 51 +- .../PlayerCommandPreprocessListener.java | 4 +- .../event/player/PlayerEditBookListener.java | 4 +- .../impl/event/player/PlayerKickListener.java | 8 +- .../menu/DiscordLinkCodeMenu.java | 24 +- .../msessentials/menu/PronounsMenu.java | 16 +- .../msessentials/menu/ResourcePackMenu.java | 64 +- .../msessentials/menu/SkinsMenu.java | 19 +- .../msessentials/player/PlayerFile.java | 10 +- .../msessentials/player/PlayerInfo.java | 84 +- .../msessentials/player/Pronouns.java | 138 +- .../player/RegistrationProcess.java | 80 +- .../resourcepack/ResourcePackLoader.java | 98 +- .../resourcepack/data/ResourcePackData.java | 136 +- .../data/ResourcePackDataImpl.java | 59 +- .../resource/GitHubPackResourceManager.java | 83 ++ .../resource/GitHubResourceManager.java | 333 ----- ...eManager.java => PackResourceManager.java} | 49 +- ...nager.java => URIPackResourceManager.java} | 40 +- .../throwable/FatalPackLoadException.java | 4 +- .../throwable/PackLoadException.java | 4 +- .../msessentials/utility/MessageUtils.java | 42 +- .../java/{ => com/minersstudios}/Main.java | 2 + 193 files changed, 6004 insertions(+), 3898 deletions(-) delete mode 100644 src/main/java/com/minersstudios/mscore/language/LanguageFile.java delete mode 100644 src/main/java/com/minersstudios/mscore/language/LanguageRegistry.java create mode 100644 src/main/java/com/minersstudios/mscore/locale/LanguageFile.java create mode 100644 src/main/java/com/minersstudios/mscore/locale/Translation.java create mode 100644 src/main/java/com/minersstudios/mscore/locale/TranslationRegistry.java create mode 100644 src/main/java/com/minersstudios/mscore/locale/TranslationRegistryImpl.java create mode 100644 src/main/java/com/minersstudios/mscore/locale/Translations.java create mode 100644 src/main/java/com/minersstudios/mscore/locale/resource/FileTranslationResourceManager.java create mode 100644 src/main/java/com/minersstudios/mscore/locale/resource/GitHubTranslationResourceManager.java create mode 100644 src/main/java/com/minersstudios/mscore/locale/resource/TranslationResourceManager.java create mode 100644 src/main/java/com/minersstudios/mscore/locale/resource/URITranslationResourceManager.java delete mode 100644 src/main/java/com/minersstudios/mscore/plugin/status/FailureStatus.java delete mode 100644 src/main/java/com/minersstudios/mscore/plugin/status/ImplPluginStatus.java delete mode 100644 src/main/java/com/minersstudios/mscore/plugin/status/PluginStatus.java delete mode 100644 src/main/java/com/minersstudios/mscore/plugin/status/SuccessStatus.java create mode 100644 src/main/java/com/minersstudios/mscore/resource/ResourceManager.java create mode 100644 src/main/java/com/minersstudios/mscore/resource/file/AbstractFileResourceManager.java create mode 100644 src/main/java/com/minersstudios/mscore/resource/file/FileResourceManager.java create mode 100644 src/main/java/com/minersstudios/mscore/resource/github/AbstractGithubResourceManager.java create mode 100644 src/main/java/com/minersstudios/mscore/resource/github/GithubResourceManager.java rename src/main/java/com/minersstudios/{msessentials/resourcepack/resource => mscore/resource/github}/Tag.java (99%) create mode 100644 src/main/java/com/minersstudios/mscore/resource/uri/AbstractURIResourceManager.java create mode 100644 src/main/java/com/minersstudios/mscore/resource/uri/URIResourceManager.java create mode 100644 src/main/java/com/minersstudios/mscore/status/FailureStatus.java create mode 100644 src/main/java/com/minersstudios/mscore/status/ImplStatus.java create mode 100644 src/main/java/com/minersstudios/mscore/status/Status.java rename src/main/java/com/minersstudios/mscore/{plugin => }/status/StatusHandler.java (71%) create mode 100644 src/main/java/com/minersstudios/mscore/status/StatusKey.java rename src/main/java/com/minersstudios/mscore/{plugin => }/status/StatusWatcher.java (52%) create mode 100644 src/main/java/com/minersstudios/mscore/status/SuccessStatus.java create mode 100644 src/main/java/com/minersstudios/mscore/status/package-info.java create mode 100644 src/main/java/com/minersstudios/msessentials/resourcepack/resource/GitHubPackResourceManager.java delete mode 100644 src/main/java/com/minersstudios/msessentials/resourcepack/resource/GitHubResourceManager.java rename src/main/java/com/minersstudios/msessentials/resourcepack/resource/{ResourceManager.java => PackResourceManager.java} (76%) rename src/main/java/com/minersstudios/msessentials/resourcepack/resource/{URIResourceManager.java => URIPackResourceManager.java} (52%) rename src/test/java/{ => com/minersstudios}/Main.java (83%) diff --git a/.editorconfig b/.editorconfig index e2a409bc..0f0e70f0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,10 +4,265 @@ root = true charset = utf-8 indent_size = 4 indent_style = space +tab_width = 4 insert_final_newline = true max_line_length = 120 ij_visual_guides = 80 ij_continuation_indent_size = 8 +[*.java] +ij_java_align_consecutive_assignments = false +ij_java_align_consecutive_variable_declarations = false +ij_java_align_group_field_declarations = false +ij_java_align_multiline_annotation_parameters = true +ij_java_align_multiline_array_initializer_expression = true +ij_java_align_multiline_assignment = false +ij_java_align_multiline_binary_operation = false +ij_java_align_multiline_chained_methods = true +ij_java_align_multiline_deconstruction_list_components = true +ij_java_align_multiline_extends_list = false +ij_java_align_multiline_for = false +ij_java_align_multiline_method_parentheses = false +ij_java_align_multiline_parameters = true +ij_java_align_multiline_parameters_in_calls = false +ij_java_align_multiline_parenthesized_expression = false +ij_java_align_multiline_records = true +ij_java_align_multiline_resources = true +ij_java_align_multiline_ternary_operation = true +ij_java_align_multiline_text_blocks = true +ij_java_align_multiline_throws_list = false +ij_java_align_subsequent_simple_methods = false +ij_java_align_throws_keyword = false +ij_java_align_types_in_multi_catch = true +ij_java_annotation_parameter_wrap = on_every_item +ij_java_array_initializer_new_line_after_left_brace = true +ij_java_array_initializer_right_brace_on_new_line = true +ij_java_array_initializer_wrap = normal +ij_java_assert_statement_colon_on_next_line = false +ij_java_assert_statement_wrap = off +ij_java_assignment_wrap = off +ij_java_binary_operation_sign_on_next_line = false +ij_java_binary_operation_wrap = off +ij_java_blank_lines_after_anonymous_class_header = 0 +ij_java_blank_lines_after_class_header = 0 +ij_java_blank_lines_after_imports = 1 +ij_java_blank_lines_after_package = 1 +ij_java_blank_lines_around_class = 1 +ij_java_blank_lines_around_field = 0 +ij_java_blank_lines_around_field_in_interface = 0 +ij_java_blank_lines_around_initializer = 1 +ij_java_blank_lines_around_method = 1 +ij_java_blank_lines_around_method_in_interface = 1 +ij_java_blank_lines_before_class_end = 0 +ij_java_blank_lines_before_imports = 1 +ij_java_blank_lines_before_method_body = 0 +ij_java_blank_lines_before_package = 0 +ij_java_block_brace_style = end_of_line +ij_java_block_comment_add_space = false +ij_java_block_comment_at_first_column = true +ij_java_call_parameters_new_line_after_left_paren = true +ij_java_call_parameters_right_paren_on_new_line = true +ij_java_call_parameters_wrap = normal +ij_java_case_statement_on_separate_line = true +ij_java_catch_on_new_line = false +ij_java_class_annotation_wrap = split_into_lines +ij_java_class_brace_style = end_of_line +ij_java_class_count_to_use_import_on_demand = 5 +ij_java_class_names_in_javadoc = 1 +ij_java_deconstruction_list_wrap = on_every_item +ij_java_do_not_indent_top_level_class_members = false +ij_java_do_not_wrap_after_single_annotation = false +ij_java_do_not_wrap_after_single_annotation_in_parameter = false +ij_java_do_while_brace_force = always +ij_java_doc_add_blank_line_after_description = true +ij_java_doc_add_blank_line_after_param_comments = false +ij_java_doc_add_blank_line_after_return = false +ij_java_doc_add_p_tag_on_empty_lines = true +ij_java_doc_align_exception_comments = true +ij_java_doc_align_param_comments = true +ij_java_doc_do_not_wrap_if_one_line = true +ij_java_doc_enable_formatting = true +ij_java_doc_enable_leading_asterisks = true +ij_java_doc_indent_on_continuation = true +ij_java_doc_keep_empty_lines = true +ij_java_doc_keep_empty_parameter_tag = true +ij_java_doc_keep_empty_return_tag = true +ij_java_doc_keep_empty_throws_tag = true +ij_java_doc_keep_invalid_tags = true +ij_java_doc_param_description_on_new_line = false +ij_java_doc_preserve_line_breaks = true +ij_java_doc_use_throws_not_exception_tag = true +ij_java_else_on_new_line = false +ij_java_enum_constants_wrap = on_every_item +ij_java_extends_keyword_wrap = off +ij_java_extends_list_wrap = off +ij_java_field_annotation_wrap = split_into_lines +ij_java_finally_on_new_line = false +ij_java_for_brace_force = always +ij_java_for_statement_new_line_after_left_paren = false +ij_java_for_statement_right_paren_on_new_line = false +ij_java_for_statement_wrap = off +ij_java_generate_final_locals = true +ij_java_generate_final_parameters = true +ij_java_if_brace_force = always +ij_java_indent_case_from_switch = true +ij_java_insert_inner_class_imports = false +ij_java_insert_override_annotation = true +ij_java_keep_blank_lines_before_right_brace = 2 +ij_java_keep_blank_lines_between_package_declaration_and_header = 2 +ij_java_keep_blank_lines_in_code = 2 +ij_java_keep_blank_lines_in_declarations = 2 +ij_java_keep_builder_methods_indents = false +ij_java_keep_control_statement_in_one_line = false +ij_java_keep_first_column_comment = false +ij_java_keep_indents_on_empty_lines = false +ij_java_keep_multiple_expressions_in_one_line = false +ij_java_keep_simple_blocks_in_one_line = false +ij_java_keep_simple_classes_in_one_line = true +ij_java_keep_simple_lambdas_in_one_line = true +ij_java_keep_simple_methods_in_one_line = true +ij_java_label_indent_absolute = false +ij_java_label_indent_size = 0 +ij_java_lambda_brace_style = end_of_line +ij_java_layout_static_imports_separately = true +ij_java_line_comment_add_space = false +ij_java_line_comment_add_space_on_reformat = false +ij_java_line_comment_at_first_column = true +ij_java_method_annotation_wrap = split_into_lines +ij_java_method_brace_style = end_of_line +ij_java_method_call_chain_wrap = on_every_item +ij_java_method_parameters_new_line_after_left_paren = true +ij_java_method_parameters_right_paren_on_new_line = true +ij_java_method_parameters_wrap = split_into_lines +ij_java_modifier_list_wrap = false +ij_java_multi_catch_types_wrap = normal +ij_java_names_count_to_use_import_on_demand = 3 +ij_java_new_line_after_lparen_in_annotation = true +ij_java_new_line_after_lparen_in_deconstruction_pattern = true +ij_java_new_line_after_lparen_in_record_header = true +ij_java_parameter_annotation_wrap = off +ij_java_parentheses_expression_new_line_after_left_paren = false +ij_java_parentheses_expression_right_paren_on_new_line = false +ij_java_place_assignment_sign_on_next_line = false +ij_java_prefer_longer_names = true +ij_java_prefer_parameters_wrap = true +ij_java_record_components_wrap = on_every_item +ij_java_repeat_synchronized = true +ij_java_replace_instanceof_and_cast = false +ij_java_replace_null_check = true +ij_java_replace_sum_lambda_with_method_ref = true +ij_java_resource_list_new_line_after_left_paren = true +ij_java_resource_list_right_paren_on_new_line = true +ij_java_resource_list_wrap = split_into_lines +ij_java_rparen_on_new_line_in_annotation = true +ij_java_rparen_on_new_line_in_deconstruction_pattern = true +ij_java_rparen_on_new_line_in_record_header = true +ij_java_space_after_closing_angle_bracket_in_type_argument = false +ij_java_space_after_colon = true +ij_java_space_after_comma = true +ij_java_space_after_comma_in_type_arguments = true +ij_java_space_after_for_semicolon = true +ij_java_space_after_quest = true +ij_java_space_after_type_cast = true +ij_java_space_before_annotation_array_initializer_left_brace = false +ij_java_space_before_annotation_parameter_list = false +ij_java_space_before_array_initializer_left_brace = false +ij_java_space_before_catch_keyword = true +ij_java_space_before_catch_left_brace = true +ij_java_space_before_catch_parentheses = true +ij_java_space_before_class_left_brace = true +ij_java_space_before_colon = true +ij_java_space_before_colon_in_foreach = true +ij_java_space_before_comma = false +ij_java_space_before_deconstruction_list = false +ij_java_space_before_do_left_brace = true +ij_java_space_before_else_keyword = true +ij_java_space_before_else_left_brace = true +ij_java_space_before_finally_keyword = true +ij_java_space_before_finally_left_brace = true +ij_java_space_before_for_left_brace = true +ij_java_space_before_for_parentheses = true +ij_java_space_before_for_semicolon = false +ij_java_space_before_if_left_brace = true +ij_java_space_before_if_parentheses = true +ij_java_space_before_method_call_parentheses = false +ij_java_space_before_method_left_brace = true +ij_java_space_before_method_parentheses = false +ij_java_space_before_opening_angle_bracket_in_type_parameter = false +ij_java_space_before_quest = true +ij_java_space_before_switch_left_brace = true +ij_java_space_before_switch_parentheses = true +ij_java_space_before_synchronized_left_brace = true +ij_java_space_before_synchronized_parentheses = true +ij_java_space_before_try_left_brace = true +ij_java_space_before_try_parentheses = true +ij_java_space_before_type_parameter_list = false +ij_java_space_before_while_keyword = true +ij_java_space_before_while_left_brace = true +ij_java_space_before_while_parentheses = true +ij_java_space_inside_one_line_enum_braces = false +ij_java_space_within_empty_array_initializer_braces = false +ij_java_space_within_empty_method_call_parentheses = false +ij_java_space_within_empty_method_parentheses = false +ij_java_spaces_around_additive_operators = true +ij_java_spaces_around_annotation_eq = true +ij_java_spaces_around_assignment_operators = true +ij_java_spaces_around_bitwise_operators = true +ij_java_spaces_around_equality_operators = true +ij_java_spaces_around_lambda_arrow = true +ij_java_spaces_around_logical_operators = true +ij_java_spaces_around_method_ref_dbl_colon = false +ij_java_spaces_around_multiplicative_operators = true +ij_java_spaces_around_relational_operators = true +ij_java_spaces_around_shift_operators = true +ij_java_spaces_around_type_bounds_in_type_parameters = true +ij_java_spaces_around_unary_operator = false +ij_java_spaces_within_angle_brackets = false +ij_java_spaces_within_annotation_parentheses = false +ij_java_spaces_within_array_initializer_braces = false +ij_java_spaces_within_braces = false +ij_java_spaces_within_brackets = false +ij_java_spaces_within_cast_parentheses = false +ij_java_spaces_within_catch_parentheses = false +ij_java_spaces_within_deconstruction_list = false +ij_java_spaces_within_for_parentheses = false +ij_java_spaces_within_if_parentheses = false +ij_java_spaces_within_method_call_parentheses = false +ij_java_spaces_within_method_parentheses = false +ij_java_spaces_within_parentheses = false +ij_java_spaces_within_record_header = false +ij_java_spaces_within_switch_parentheses = false +ij_java_spaces_within_synchronized_parentheses = false +ij_java_spaces_within_try_parentheses = false +ij_java_spaces_within_while_parentheses = false +ij_java_special_else_if_treatment = true +ij_java_ternary_operation_signs_on_next_line = true +ij_java_ternary_operation_wrap = split_into_lines +ij_java_throws_keyword_wrap = off +ij_java_throws_list_wrap = off +ij_java_use_external_annotations = false +ij_java_use_fq_class_names = false +ij_java_use_relative_indents = false +ij_java_use_single_class_imports = true +ij_java_variable_annotation_wrap = off +ij_java_while_brace_force = always +ij_java_while_on_new_line = false +ij_java_wrap_comments = true +ij_java_wrap_first_method_in_call_chain = false +ij_java_wrap_long_lines = false + [*.yml] indent_size = 2 + +[*.json] +ij_json_property_alignment = align_on_value +ij_json_array_wrapping = off +ij_json_object_wrapping = off +ij_json_keep_line_breaks = true +ij_json_spaces_within_braces = true +ij_json_spaces_within_brackets = true +ij_json_space_after_colon = true +ij_json_space_after_comma = true +ij_json_space_before_colon = false +ij_json_space_before_comma = false +ij_json_wrap_long_lines = false diff --git a/src/main/java/com/minersstudios/mscore/MSCore.java b/src/main/java/com/minersstudios/mscore/MSCore.java index 94280b6a..b19ddc97 100644 --- a/src/main/java/com/minersstudios/mscore/MSCore.java +++ b/src/main/java/com/minersstudios/mscore/MSCore.java @@ -1,7 +1,5 @@ package com.minersstudios.mscore; -import com.minersstudios.mscore.language.LanguageFile; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.plugin.MSPlugin; import com.minersstudios.mscore.utility.CoreProtectUtils; @@ -13,7 +11,7 @@ import java.util.logging.Logger; -import static com.minersstudios.mscore.language.LanguageRegistry.Keys.ERROR_NO_PERMISSION; +import static com.minersstudios.mscore.locale.Translations.*; import static com.minersstudios.mscore.utility.Font.Chars.RED_EXCLAMATION_MARK; /** @@ -27,30 +25,30 @@ public final class MSCore extends MSPlugin { public static final String NAMESPACE = "mscore"; // - private static final String CONNECTION_THROTTLE = "messages.kick.connection-throttle"; - private static final String FLYING_PLAYER = "messages.kick.flying-player"; - private static final String FLYING_VEHICLE = "messages.kick.flying-vehicle"; - private static final String NO_PERMISSION = "messages.no-permission"; - private static final String TOO_MANY_PACKETS = "packet-limiter.kick-message"; + private static final String KEY_CONNECTION_THROTTLE = "messages.kick.connection-throttle"; + private static final String KEY_FLYING_PLAYER = "messages.kick.flying-player"; + private static final String KEY_FLYING_VEHICLE = "messages.kick.flying-vehicle"; + private static final String KEY_NO_PERMISSION = "messages.no-permission"; + private static final String KEY_TOO_MANY_PACKETS = "packet-limiter.kick-message"; // - // - private static final String MESSAGE_CONNECTION_THROTTLE = "'; - private static final String MESSAGE_FLYING_PLAYER = "'; - private static final String MESSAGE_FLYING_VEHICLE = "'; - private static final String MESSAGE_NO_PERMISSION = ' ' + RED_EXCLAMATION_MARK + " '; - private static final String MESSAGE_TOO_MANY_PACKETS = "'; + // + private static final String VALUE_CONNECTION_THROTTLE = "'; + private static final String VALUE_FLYING_PLAYER = "'; + private static final String VALUE_FLYING_VEHICLE = "'; + private static final String VALUE_NO_PERMISSION = ' ' + RED_EXCLAMATION_MARK + " '; + private static final String VALUE_TOO_MANY_PACKETS = "'; // @Override public void load() { PaperUtils .editConfig(PaperUtils.ConfigType.GLOBAL, this.getServer()) - .set(CONNECTION_THROTTLE, MESSAGE_CONNECTION_THROTTLE) - .set(FLYING_PLAYER, MESSAGE_FLYING_PLAYER) - .set(FLYING_VEHICLE, MESSAGE_FLYING_VEHICLE) - .set(NO_PERMISSION, MESSAGE_NO_PERMISSION) - .set(TOO_MANY_PACKETS, MESSAGE_TOO_MANY_PACKETS) + .set(KEY_CONNECTION_THROTTLE, VALUE_CONNECTION_THROTTLE) + .set(KEY_FLYING_PLAYER, VALUE_FLYING_PLAYER) + .set(KEY_FLYING_VEHICLE, VALUE_FLYING_VEHICLE) + .set(KEY_NO_PERMISSION, VALUE_NO_PERMISSION) + .set(KEY_TOO_MANY_PACKETS, VALUE_TOO_MANY_PACKETS) .save(); } @@ -59,20 +57,11 @@ public void enable() { singleton = this; this.setupCoreProtect(); - - if (!LanguageFile.isLoaded()) { - LanguageFile.loadLanguage( - globalConfig().getLanguageFolderLink(), - globalConfig().getLanguageCode() - ); - } } @Override public void disable() { singleton = null; - - LanguageFile.unloadLanguage(); } /** @@ -87,18 +76,12 @@ public void setupCoreProtect() { if (coreProtect == null) { MSLogger.warning("CoreProtectAPI is not running yet"); - - return; - } - - if (coreProtect.isEnabled()) { + } else if (coreProtect.isEnabled()) { CoreProtectUtils.set(coreProtect.getAPI()); MSLogger.fine("CoreProtect connected"); - - return; + } else { + MSLogger.warning("CoreProtect is not Enabled, actions logging will not be available"); } - - MSLogger.warning("CoreProtect is not Enabled, actions logging will not be available"); } catch (final IllegalStateException e) { MSLogger.warning("CoreProtect is already connected"); } catch (final NoClassDefFoundError e) { diff --git a/src/main/java/com/minersstudios/mscore/command/impl/ReloadConfigCommand.java b/src/main/java/com/minersstudios/mscore/command/impl/ReloadConfigCommand.java index a76a0ddd..86217a27 100644 --- a/src/main/java/com/minersstudios/mscore/command/impl/ReloadConfigCommand.java +++ b/src/main/java/com/minersstudios/mscore/command/impl/ReloadConfigCommand.java @@ -1,6 +1,6 @@ package com.minersstudios.mscore.command.impl; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.plugin.MSPlugin; import org.bukkit.command.CommandSender; @@ -16,7 +16,7 @@ public static boolean runCommand(final @NotNull CommandSender sender) { MSPlugin.globalConfig().reload(); MSLogger.fine( sender, - LanguageRegistry.Components.COMMAND_MSCORE_RELOAD_CONFIG_SUCCESS + Translations.COMMAND_MSCORE_RELOAD_CONFIG_SUCCESS.asTranslatable() .arguments(text(System.currentTimeMillis() - time)) ); diff --git a/src/main/java/com/minersstudios/mscore/inventory/plugin/InventoryHolder.java b/src/main/java/com/minersstudios/mscore/inventory/plugin/InventoryHolder.java index 8bd34054..9a7ab633 100644 --- a/src/main/java/com/minersstudios/mscore/inventory/plugin/InventoryHolder.java +++ b/src/main/java/com/minersstudios/mscore/inventory/plugin/InventoryHolder.java @@ -1,9 +1,6 @@ package com.minersstudios.mscore.inventory.plugin; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * All event listeners annotated using {@link InventoryHolder} will be registered @@ -11,6 +8,7 @@ * * @see AbstractInventoryHolder */ +@Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface InventoryHolder {} diff --git a/src/main/java/com/minersstudios/mscore/inventory/recipe/builder/RecipeBuilder.java b/src/main/java/com/minersstudios/mscore/inventory/recipe/builder/RecipeBuilder.java index 13b75a31..70420d15 100644 --- a/src/main/java/com/minersstudios/mscore/inventory/recipe/builder/RecipeBuilder.java +++ b/src/main/java/com/minersstudios/mscore/inventory/recipe/builder/RecipeBuilder.java @@ -19,131 +19,131 @@ public interface RecipeBuilder { @NotNull RecipeBuilder result(final @NotNull ItemStack result) throws IllegalArgumentException; @Contract(" -> new") - static @NotNull ShapedRecipeBuilder shapedBuilder() { + static @NotNull ShapedRecipeBuilder shaped() { return new ShapedRecipeBuilder(); } @Contract("_ -> new") - static @NotNull ShapedRecipeBuilder shapedBuilder(final @NotNull ShapedRecipe recipe) { + static @NotNull ShapedRecipeBuilder shaped(final @NotNull ShapedRecipe recipe) { return new ShapedRecipeBuilder(recipe); } @Contract(" -> new") - static @NotNull ShapelessRecipeBuilder shapelessBuilder() { + static @NotNull ShapelessRecipeBuilder shapeless() { return new ShapelessRecipeBuilder(); } @Contract("_ -> new") - static @NotNull ShapelessRecipeBuilder shapelessBuilder(final @NotNull ShapelessRecipe recipe) { + static @NotNull ShapelessRecipeBuilder shapeless(final @NotNull ShapelessRecipe recipe) { return new ShapelessRecipeBuilder(recipe); } @Contract(" -> new") - static @NotNull FurnaceRecipeBuilder furnaceBuilder() { + static @NotNull FurnaceRecipeBuilder furnace() { return new FurnaceRecipeBuilder(); } @Contract("_ -> new") - static @NotNull FurnaceRecipeBuilder furnaceBuilder(final @NotNull FurnaceRecipe recipe) { + static @NotNull FurnaceRecipeBuilder furnace(final @NotNull FurnaceRecipe recipe) { return new FurnaceRecipeBuilder(recipe); } @Contract(" -> new") - static @NotNull SmokingRecipeBuilder smokingBuilder() { + static @NotNull SmokingRecipeBuilder smoking() { return new SmokingRecipeBuilder(); } @Contract("_ -> new") - static @NotNull SmokingRecipeBuilder smokingBuilder(final @NotNull SmokingRecipe recipe) { + static @NotNull SmokingRecipeBuilder smoking(final @NotNull SmokingRecipe recipe) { return new SmokingRecipeBuilder(recipe); } @Contract(" -> new") - static @NotNull BlastingRecipeBuilder blastingBuilder() { + static @NotNull BlastingRecipeBuilder blasting() { return new BlastingRecipeBuilder(); } @Contract("_ -> new") - static @NotNull BlastingRecipeBuilder blastingBuilder(final @NotNull BlastingRecipe recipe) { + static @NotNull BlastingRecipeBuilder blasting(final @NotNull BlastingRecipe recipe) { return new BlastingRecipeBuilder(recipe); } @Contract(" -> new") - static @NotNull CampfireRecipeBuilder campfireBuilder() { + static @NotNull CampfireRecipeBuilder campfire() { return new CampfireRecipeBuilder(); } @Contract("_ -> new") - static @NotNull CampfireRecipeBuilder campfireBuilder(final @NotNull CampfireRecipe recipe) { + static @NotNull CampfireRecipeBuilder campfire(final @NotNull CampfireRecipe recipe) { return new CampfireRecipeBuilder(recipe); } @Contract(" -> new") - static @NotNull StonecuttingRecipeBuilder stonecuttingBuilder() { + static @NotNull StonecuttingRecipeBuilder stonecutting() { return new StonecuttingRecipeBuilder(); } @Contract("_ -> new") - static @NotNull StonecuttingRecipeBuilder stonecuttingBuilder(final @NotNull StonecuttingRecipe recipe) { + static @NotNull StonecuttingRecipeBuilder stonecutting(final @NotNull StonecuttingRecipe recipe) { return new StonecuttingRecipeBuilder(recipe); } @Contract(" -> new") - static @NotNull SmithingTransformRecipeBuilder smithingTransformBuilder() { + static @NotNull SmithingTransformRecipeBuilder smithingTransform() { return new SmithingTransformRecipeBuilder(); } @Contract("_ -> new") - static @NotNull SmithingTransformRecipeBuilder smithingTransformBuilder(final @NotNull SmithingTransformRecipe recipe) { + static @NotNull SmithingTransformRecipeBuilder smithingTransform(final @NotNull SmithingTransformRecipe recipe) { return new SmithingTransformRecipeBuilder(recipe); } @Contract(" -> new") - static @NotNull SmithingTrimRecipeBuilder smithingTrimBuilder() { + static @NotNull SmithingTrimRecipeBuilder smithingTrim() { return new SmithingTrimRecipeBuilder(); } @Contract("_ -> new") - static @NotNull SmithingTrimRecipeBuilder smithingTrimBuilder(final @NotNull SmithingTrimRecipe recipe) { + static @NotNull SmithingTrimRecipeBuilder smithingTrim(final @NotNull SmithingTrimRecipe recipe) { return new SmithingTrimRecipeBuilder(recipe); } @Contract("_ -> new") - static @NotNull RecipeBuilder unknownRecipeBuilder(final @NotNull Recipe recipe) throws UnsupportedOperationException { + static @NotNull RecipeBuilder unknown(final @NotNull Recipe recipe) throws UnsupportedOperationException { if (recipe instanceof final ShapedRecipe shaped) { - return shapedBuilder(shaped); + return shaped(shaped); } if (recipe instanceof final ShapelessRecipe shapeless) { - return shapelessBuilder(shapeless); + return shapeless(shapeless); } if (recipe instanceof final FurnaceRecipe furnace) { - return furnaceBuilder(furnace); + return furnace(furnace); } if (recipe instanceof final SmokingRecipe smoking) { - return smokingBuilder(smoking); + return smoking(smoking); } if (recipe instanceof final BlastingRecipe blasting) { - return blastingBuilder(blasting); + return blasting(blasting); } if (recipe instanceof final CampfireRecipe campfire) { - return campfireBuilder(campfire); + return campfire(campfire); } if (recipe instanceof final StonecuttingRecipe stonecutting) { - return stonecuttingBuilder(stonecutting); + return stonecutting(stonecutting); } if (recipe instanceof final SmithingTransformRecipe smithingTransform) { - return smithingTransformBuilder(smithingTransform); + return smithingTransform(smithingTransform); } if (recipe instanceof final SmithingTrimRecipe smithingTrim) { - return smithingTrimBuilder(smithingTrim); + return smithingTrim(smithingTrim); } throw new UnsupportedOperationException("Unknown recipe type: " + recipe.getClass().getName()); diff --git a/src/main/java/com/minersstudios/mscore/inventory/recipe/choice/CustomChoice.java b/src/main/java/com/minersstudios/mscore/inventory/recipe/choice/CustomChoice.java index 4fb7541b..ca9dcc1a 100644 --- a/src/main/java/com/minersstudios/mscore/inventory/recipe/choice/CustomChoice.java +++ b/src/main/java/com/minersstudios/mscore/inventory/recipe/choice/CustomChoice.java @@ -1,6 +1,10 @@ package com.minersstudios.mscore.inventory.recipe.choice; +import com.google.common.collect.Maps; +import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscustoms.utility.MSCustomUtils; +import it.unimi.dsi.fastutil.objects.Object2ObjectMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.RecipeChoice; @@ -9,6 +13,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; +import javax.annotation.concurrent.Immutable; import java.util.*; import java.util.regex.Pattern; @@ -20,9 +25,9 @@ * Use {@link #toExactChoice()} to convert this choice to an {@link ExactChoice}. * It is important because bukkit does not support custom choices. */ +@Immutable public final class CustomChoice implements RecipeChoice { - private List choices; - private List namespacedKeys; + private Object2ObjectMap choiceMap; private static final String REGEX = "[a-z0-9/._-]+:[a-z0-9/._-]+"; private static final Pattern PATTERN = Pattern.compile(REGEX); @@ -56,85 +61,127 @@ public CustomChoice(final String @NotNull ... namespacedKeys) throws IllegalArgu * any of the namespaced keys are null or * invalid */ - public CustomChoice(final @NotNull List namespacedKeys) throws IllegalArgumentException { + public CustomChoice(final @NotNull Collection namespacedKeys) throws IllegalArgumentException { if (namespacedKeys.isEmpty()) { throw new IllegalArgumentException("Must have at least one namespacedKey"); } - this.namespacedKeys = namespacedKeys; - this.choices = new ObjectArrayList<>(); + this.choiceMap = new Object2ObjectOpenHashMap<>(namespacedKeys.size()); for (final var namespacedKey : namespacedKeys) { - if (namespacedKey == null) { - throw new IllegalArgumentException("Cannot have null namespacedKey"); + if (ChatUtils.isBlank(namespacedKey)) { + throw new IllegalArgumentException("Cannot have a blank namespacedKey"); } if (!PATTERN.matcher(namespacedKey).matches()) { - throw new IllegalArgumentException("Invalid namespacedKey: " + namespacedKey); + throw new IllegalArgumentException("Invalid namespacedKey : " + namespacedKey); } MSCustomUtils.getItemStack(namespacedKey) - .ifPresent(itemStack -> this.choices.add(itemStack)); + .ifPresent(itemStack -> this.choiceMap.put(namespacedKey, itemStack)); } } /** + * Returns a clone of the first item stack + * * @return A clone of the first item stack - * @deprecated Use {@link #getChoices()} instead + * @deprecated Use {@link #choices()} or {@link #getItemStack(String)} + * instead */ @Deprecated @Override public @NotNull ItemStack getItemStack() { - return this.choices.get(0).clone(); + return this.choiceMap.values().iterator().next().clone(); + } + + /** + * Returns a clone of the item stack for the specified namespaced key + * + * @param namespacedKey The namespaced key to get the item stack for + * @return A clone of the item stack for the specified namespaced key + */ + public @NotNull ItemStack getItemStack(final @NotNull String namespacedKey) { + return this.choiceMap.get(namespacedKey).clone(); } /** + * Returns the first namespaced key + * * @return The first namespaced key */ public @NotNull String getNamespacedKey() { - return this.namespacedKeys.get(0); + return this.choiceMap.keySet().iterator().next(); } /** - * @return An unmodifiable view of the choices + * Returns an unmodifiable set of the namespaced keys + * + * @return An unmodifiable set of the namespaced keys */ - public @NotNull @Unmodifiable List getChoices() { - return Collections.unmodifiableList(this.choices); + public @NotNull @Unmodifiable Set namespacedKeySet() { + return Collections.unmodifiableSet(this.choiceMap.keySet()); } /** - * @return An unmodifiable view of the namespaced keys + * Returns an unmodifiable collection of the choices + * + * @return An unmodifiable collection of the choices */ - public @NotNull @Unmodifiable List getNamespacedKeys() { - return Collections.unmodifiableList(this.namespacedKeys); + public @NotNull @Unmodifiable Collection choices() { + return Collections.unmodifiableCollection(this.choiceMap.values()); } /** - * Creates and returns a clone of this CustomChoice + * Returns an unmodifiable set of the entries * - * @return A clone of this choice + * @return An unmodifiable set of the entries + */ + public @NotNull @Unmodifiable Set> entrySet() { + return Collections.unmodifiableSet(this.choiceMap.object2ObjectEntrySet()); + } + + /** + * @return A hash code based on the choices */ @Override - public @NotNull CustomChoice clone() { - try { - final CustomChoice clone = (CustomChoice) super.clone(); + public int hashCode() { + return this.choiceMap.hashCode(); + } - clone.choices = new ObjectArrayList<>(this.choices); - clone.namespacedKeys = new ObjectArrayList<>(this.namespacedKeys); + /** + * @param obj The object to compare + * @return True if the object is a CustomChoice and has the same choices + */ + @Contract("null -> false") + @Override + public boolean equals(final @Nullable Object obj) { + return this == obj + || ( + obj instanceof CustomChoice that + && Maps.difference(this.choiceMap, that.choiceMap).areEqual() + ); + } - return clone; - } catch (final CloneNotSupportedException e) { - throw new AssertionError("An error occurred while cloning '" + this + "'", e); - } + /** + * Returns whether the namespaced key is present in the choices + * + * @param namespacedKey The namespaced key to test + * @return True if the namespaced key is present in the choices + */ + public boolean test(final @NotNull String namespacedKey) { + return this.choiceMap.containsKey(namespacedKey); } /** + * Returns whether the itemStack is similar to any of the choices + * * @param itemStack The input itemStack to test * @return True if the itemStack is similar to any of the choices */ @Override public boolean test(final @NotNull ItemStack itemStack) { - for (final var choice : this.choices) { + for (final var choice : this.choiceMap.values()) { if (choice.isSimilar(itemStack)) { return true; } @@ -144,34 +191,31 @@ public boolean test(final @NotNull ItemStack itemStack) { } /** - * @return A hash code based on the choices + * Creates and returns a clone of this {@code CustomChoice} + * + * @return A clone of this choice */ @Override - public int hashCode() { - return 41 * 7 + Objects.hashCode(this.choices); - } + public @NotNull CustomChoice clone() { + try { + final CustomChoice clone = (CustomChoice) super.clone(); - /** - * @param obj The object to compare - * @return True if the object is a CustomChoice and has the same choices - */ - @Contract("null -> false") - @Override - public boolean equals(final @Nullable Object obj) { - return this == obj - || ( - obj != null - && this.getClass() == obj.getClass() - && Objects.equals(this.choices, ((CustomChoice) obj).choices) - ); + clone.choiceMap = new Object2ObjectOpenHashMap<>(this.choiceMap); + + return clone; + } catch (final CloneNotSupportedException e) { + throw new AssertionError("An error occurred while cloning '" + this + "'", e); + } } /** + * Returns a string representation of this choice + * * @return A string representation of this choice */ @Override public @NotNull String toString() { - return "CustomChoice{choices=" + this.choices + '}'; + return this.getClass().getSimpleName() + this.choiceMap; } /** @@ -181,6 +225,6 @@ public boolean equals(final @Nullable Object obj) { * @return A new ExactChoice with the same choices as this CustomChoice */ public @NotNull ExactChoice toExactChoice() { - return new ExactChoice(this.choices); + return new ExactChoice(new ObjectArrayList<>(this.choiceMap.values())); } } diff --git a/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/BuilderRecipeEntry.java b/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/BuilderRecipeEntry.java index 0ae849cd..f742a565 100644 --- a/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/BuilderRecipeEntry.java +++ b/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/BuilderRecipeEntry.java @@ -4,9 +4,6 @@ import org.bukkit.inventory.Recipe; import org.jetbrains.annotations.NotNull; -import javax.annotation.concurrent.Immutable; - -@Immutable final class BuilderRecipeEntry extends RecipeEntryImpl { private final RecipeBuilder builder; diff --git a/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/RecipeEntry.java b/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/RecipeEntry.java index 6d050b7b..75a3efdd 100644 --- a/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/RecipeEntry.java +++ b/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/RecipeEntry.java @@ -15,10 +15,10 @@ *
* Factory methods : *
    - *
  • {@link #of(RecipeBuilder)}
  • - *
  • {@link #of(Recipe)}
  • - *
  • {@link #of(RecipeBuilder, boolean)}
  • - *
  • {@link #of(Recipe, boolean)}
  • + *
  • {@link #fromBuilder(RecipeBuilder)}
  • + *
  • {@link #fromBuilder(RecipeBuilder, boolean)}
  • + *
  • {@link #fromRecipe(Recipe)}
  • + *
  • {@link #fromRecipe(Recipe, boolean)}
  • *
* * @see #isSupportedInCraftsMenu(Recipe) @@ -27,50 +27,64 @@ public interface RecipeEntry { /** - * @return The recipe builder associated with this RecipeEntry. - *
- * If a recipe builder was not used to create this RecipeEntry, a - * new recipe builder will be created and returned from the recipe. + * Returns the recipe builder associated with this RecipeEntry. + *
+ * If a recipe builder was not used to create this RecipeEntry, a new recipe + * builder will be created and returned from the recipe. + * + * @return The recipe builder associated with this RecipeEntry * @throws UnsupportedOperationException If the recipe is unsupported in * the recipe builder */ @NotNull RecipeBuilder getBuilder() throws UnsupportedOperationException; /** - * @return The Bukkit Recipe object associated with this RecipeEntry. - *
- * If a recipe builder was used to create this RecipeEntry, the - * recipe will be built and returned. + * Returns the Bukkit Recipe object associated with this RecipeEntry. + *
+ * If a recipe builder was used to create this RecipeEntry, the recipe will + * be built and returned. + * + * @return The Bukkit Recipe object associated with this RecipeEntry */ @NotNull Recipe getRecipe(); /** + * Returns a hash code based on the recipe and isRegisteredInMenu flag + * * @return A hash code based on the recipe and isRegisteredInMenu flag */ @Override int hashCode(); /** + * Compares the specified object with this RecipeEntry for equality + * + * @param obj The object to compare + * @return True if the object is a RecipeEntry and has the same recipe and + * isRegisteredInMenu flag + */ + @Contract("null -> false") + @Override + boolean equals(final @Nullable Object obj); + + /** + * Returns whether the recipe should be shown in the {@link CraftsMenu} + * * @return True if the recipe should be shown in the {@link CraftsMenu} */ boolean isRegisteredInMenu(); /** + * Returns whether the recipe created with the recipe builder + * * @return True if the recipe created with the recipe builder */ boolean isBuildable(); /** - * @param obj The object to compare - * @return True if the object is a RecipeEntry and has the same recipe and - * isRegisteredInMenu flag - */ - @Contract("null -> false") - @Override - boolean equals(final @Nullable Object obj); - - /** - * @return A string representation of this RecipeEntry + * Returns a string representation of this {@code RecipeEntry} + * + * @return A string representation of this {@code RecipeEntry} */ @Override @NotNull String toString(); @@ -81,11 +95,11 @@ public interface RecipeEntry { * * @param builder The recipe builder * @return A new RecipeEntry - * @see #of(RecipeBuilder, boolean) + * @see #fromBuilder(RecipeBuilder, boolean) */ @Contract("_ -> new") - static @NotNull RecipeEntry of(final @NotNull RecipeBuilder builder) { - return of(builder, false); + static @NotNull RecipeEntry fromBuilder(final @NotNull RecipeBuilder builder) { + return fromBuilder(builder, false); } /** @@ -102,7 +116,7 @@ public interface RecipeEntry { * @see #isSupportedInCraftsMenu(RecipeBuilder) */ @Contract("_, _ -> new") - static @NotNull RecipeEntry of( + static @NotNull RecipeEntry fromBuilder( final @NotNull RecipeBuilder builder, final boolean isRegisteredInMenu ) { @@ -119,11 +133,11 @@ && isSupportedInCraftsMenu(builder) * * @param recipe The Bukkit Recipe object * @return A new RecipeEntry - * @see #of(Recipe, boolean) + * @see #fromRecipe(Recipe, boolean) */ @Contract("_ -> new") - static @NotNull RecipeEntry of(final @NotNull Recipe recipe) { - return of(recipe, false); + static @NotNull RecipeEntry fromRecipe(final @NotNull Recipe recipe) { + return fromRecipe(recipe, false); } /** @@ -140,7 +154,7 @@ && isSupportedInCraftsMenu(builder) * @see #isSupportedInCraftsMenu(Recipe) */ @Contract("_, _ -> new") - static @NotNull RecipeEntry of( + static @NotNull RecipeEntry fromRecipe( final @NotNull Recipe recipe, final boolean isRegisteredInMenu ) { @@ -152,6 +166,8 @@ && isSupportedInCraftsMenu(recipe) } /** + * Returns whether the recipe type is supported in the {@link CraftsMenu} + * * @param recipe The Bukkit Recipe object * @return True if the recipe type is supported in the {@link CraftsMenu} */ @@ -160,6 +176,9 @@ static boolean isSupportedInCraftsMenu(final @NotNull Recipe recipe) { } /** + * Returns whether the recipe builder type is supported in the + * {@link CraftsMenu} + * * @param builder The recipe builder * @return True if the recipe builder type is supported in the * {@link CraftsMenu} diff --git a/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/RecipeEntryImpl.java b/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/RecipeEntryImpl.java index 0d52dd6e..c621f91f 100644 --- a/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/RecipeEntryImpl.java +++ b/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/RecipeEntryImpl.java @@ -25,14 +25,9 @@ public final int hashCode() { return result; } - @Override - public final boolean isRegisteredInMenu() { - return this.isRegisteredInMenu; - } - @Contract("null -> false") @Override - public final boolean equals(final @Nullable Object obj) { + public boolean equals(final @Nullable Object obj) { return this == obj || ( obj instanceof RecipeEntryImpl that @@ -41,6 +36,11 @@ public final boolean equals(final @Nullable Object obj) { ); } + @Override + public final boolean isRegisteredInMenu() { + return this.isRegisteredInMenu; + } + @Override public abstract @NotNull String toString(); } diff --git a/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/SimpleRecipeEntry.java b/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/SimpleRecipeEntry.java index b3c28446..ab617120 100644 --- a/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/SimpleRecipeEntry.java +++ b/src/main/java/com/minersstudios/mscore/inventory/recipe/entry/SimpleRecipeEntry.java @@ -21,7 +21,7 @@ final class SimpleRecipeEntry extends RecipeEntryImpl { @Override public @NotNull RecipeBuilder getBuilder() throws UnsupportedOperationException { - return RecipeBuilder.unknownRecipeBuilder(this.recipe); + return RecipeBuilder.unknown(this.recipe); } @Override diff --git a/src/main/java/com/minersstudios/mscore/language/LanguageFile.java b/src/main/java/com/minersstudios/mscore/language/LanguageFile.java deleted file mode 100644 index 0e369d7c..00000000 --- a/src/main/java/com/minersstudios/mscore/language/LanguageFile.java +++ /dev/null @@ -1,302 +0,0 @@ -package com.minersstudios.mscore.language; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; -import com.minersstudios.mscore.utility.SharedConstants; -import com.minersstudios.mscore.plugin.GlobalConfig; -import com.minersstudios.mscore.plugin.MSLogger; -import com.minersstudios.mscore.plugin.MSPlugin; -import com.minersstudios.mscore.utility.ChatUtils; -import net.kyori.adventure.key.Key; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.TranslatableComponent; -import net.kyori.adventure.translation.GlobalTranslator; -import net.kyori.adventure.translation.TranslationRegistry; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.lang.reflect.Field; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.text.MessageFormat; -import java.util.Locale; -import java.util.Map; - -import static net.kyori.adventure.text.Component.translatable; - -/** - * Language file loader. Loads the language file from the language repository - * and adds it to {@link GlobalTranslator}. All downloaded language files are - * stored in the {@link SharedConstants#LANGUAGE_FOLDER_PATH} folder. - */ -public final class LanguageFile { - private static TranslationRegistry registry = TranslationRegistry.create(Key.key("ms")); - - private final String folderLink; - private final String code; - private final JsonObject translations; - private File file; - - private static final String OLD_FILE_SUFFIX = ".OLD"; - private static final Field TRANSLATIONS_FIELD; - - static { - try { - final var registryImplClass = Class.forName("net.kyori.adventure.translation.TranslationRegistryImpl"); - TRANSLATIONS_FIELD = registryImplClass.getDeclaredField("translations"); - - TRANSLATIONS_FIELD.setAccessible(true); - } catch (final Throwable e) { - throw new IllegalStateException("Failed to initialize LanguageFile", e); - } - } - - private LanguageFile( - final @NotNull String folderLink, - final @NotNull String code - ) { - this.folderLink = folderLink; - this.code = code; - this.file = this.loadFile(); - this.translations = this.loadTranslations(); - } - - /** - * @return The folder link of the language repository - */ - public @NotNull String getFolderLink() { - return this.folderLink; - } - - /** - * @return The language code of the language file - */ - public @NotNull String getCode() { - return this.code; - } - - /** - * @return The language file - */ - public @NotNull File getFile() { - return this.file; - } - - /** - * @return The translation registry of the language file - */ - public @NotNull TranslationRegistry getRegistry() { - return registry; - } - - /** - * Loads the translations from the language file to {@link GlobalTranslator}. - * If the language file does not exist, it will be downloaded from the - * language repository. - * - * @param folderLink The folder link of the language repository - * @param code Language code of the language file - */ - public static void loadLanguage( - final @NotNull String folderLink, - final @NotNull String code - ) { - final long time = System.currentTimeMillis(); - final LanguageFile languageFile = new LanguageFile(folderLink, code); - - languageFile.translations.entrySet().forEach( - entry -> { - final String key = entry.getKey(); - final String value = entry.getValue().getAsString(); - - if (registry.contains(key)) { - registry.unregister(key); - } - - registry.register(key, Locale.US, new MessageFormat(value)); - } - ); - GlobalTranslator.translator().addSource(registry); - - MSLogger.fine( - "Loaded language file: " + languageFile.file.getName() + " in " + (System.currentTimeMillis() - time) + "ms" - ); - } - - /** - * Unloads all languages registered in {@link #registry} from - * {@link GlobalTranslator} - */ - public static void unloadLanguage() { - GlobalTranslator.translator().removeSource(registry); - registry = TranslationRegistry.create(Key.key("ms")); - } - - /** - * Reloads language file - * - * @see #unloadLanguage() - * @see #loadLanguage(String, String) - */ - public static void reloadLanguage() { - final GlobalConfig config = MSPlugin.globalConfig(); - - unloadLanguage(); - loadLanguage(config.getLanguageFolderLink(), config.getLanguageCode()); - } - - /** - * Renders the translation from {@link #registry} as - * {@link TranslatableComponent}. - *
- * NOTE: Use only for custom translations loaded from the language - * file. Usually used for item names and lore, because they are rendered it - * without a fallback - * - * @param key Translation key - * @return TranslatableComponent with translation from {@link #registry} or - * key if translation is not found - * @see #renderTranslation(String) - */ - public static @NotNull TranslatableComponent renderTranslationComponent(final @NotNull String key) { - return translatable(key, renderTranslation(key)); - } - - /** - * Renders the translation from {@link GlobalTranslator} as {@link Component} - * - * @param translatable TranslatableComponent to render - * @return Translated component or key if translation is not found - */ - public static @NotNull Component renderTranslationComponent(final @NotNull TranslatableComponent translatable) { - return GlobalTranslator.render(translatable, Locale.US); - } - - /** - * Renders the translation from {@link #registry} as {@link String} - *
- * NOTE: Use only for custom translations loaded from language file - * - * @param key Translation key - * @return Translated string or key if translation is not found - */ - public static @NotNull String renderTranslation(final @NotNull String key) { - final MessageFormat format = registry.translate(key, Locale.US); - return format == null ? key : format.toPattern(); - } - - /** - * Renders the translation from {@link GlobalTranslator} as {@link String} - * - * @param translatable TranslatableComponent to render - * @return Translated string or key if translation is not found - */ - public static @NotNull String renderTranslation(final @NotNull TranslatableComponent translatable) { - return ChatUtils.serializePlainComponent( - renderTranslationComponent(translatable) - ); - } - - /** - * @return True if language is loaded - * (if {@link #registry} is not empty) - */ - public static boolean isLoaded() { - try { - return !((Map) TRANSLATIONS_FIELD.get(registry)).isEmpty(); - } catch (final IllegalAccessException e) { - MSLogger.severe("Failed to check if language is loaded", e); - return false; - } - } - - /** - * Loads language file from the language repository. File will be downloaded - * to {@link SharedConstants#LANGUAGE_FOLDER_PATH} folder. - * - * @return Language file - */ - private @NotNull File loadFile() { - final File langFolder = new File(SharedConstants.LANGUAGE_FOLDER_PATH); - - if ( - !langFolder.exists() - && !langFolder.mkdirs() - ) { - MSLogger.severe("Failed to create language folder"); - } - - final File langFile = new File(langFolder, this.code + ".json"); - - if (!langFile.exists()) { - final String link = - this.folderLink - + ( - this.folderLink.endsWith("/") - ? "" - : '/' - ) - + this.code + ".json"; - - try ( - final var in = new URL(link).openStream(); - final var out = new FileOutputStream(langFile) - ) { - in.transferTo(out); - } catch (final IOException e) { - MSLogger.severe("Failed to download language file: " + link, e); - } - } - - return langFile; - } - - /** - * Loads language file as {@link JsonObject} from the file path specified in - * {@link #file} - * - * @return JsonObject of language file - * @throws JsonSyntaxException If language file is corrupted - */ - private @NotNull JsonObject loadTranslations() throws JsonSyntaxException { - try { - final Path path = Path.of(this.file.getAbsolutePath()); - final String content = Files.readString(path); - final JsonElement element = JsonParser.parseString(content); - - return element.getAsJsonObject(); - } catch (final IOException | JsonSyntaxException e) { - MSLogger.severe("Failed to load corrupted language file: " + this.code + ".json"); - MSLogger.severe("Creating backup file and trying to load language file again"); - - this.createBackupFile(); - this.file = this.loadFile(); - - return this.loadTranslations(); - } - } - - /** - * Creates a backup file of the corrupted language file. The backup file - * will be named as the original file with {@link #OLD_FILE_SUFFIX} appended - * to the end. If the backup file already exists, it will be replaced - */ - private void createBackupFile() { - final String backupFileName = this.file.getName() + OLD_FILE_SUFFIX; - final File backupFile = new File(this.file.getParent(), backupFileName); - final Path filePath = Path.of(this.file.getAbsolutePath()); - final Path backupFilePath = Path.of(backupFile.getAbsolutePath()); - - try { - Files.move(filePath, backupFilePath, StandardCopyOption.REPLACE_EXISTING); - } catch (final IOException e) { - MSLogger.severe("Failed to create backup file: " + backupFileName, e); - } - } -} diff --git a/src/main/java/com/minersstudios/mscore/language/LanguageRegistry.java b/src/main/java/com/minersstudios/mscore/language/LanguageRegistry.java deleted file mode 100644 index ef741a07..00000000 --- a/src/main/java/com/minersstudios/mscore/language/LanguageRegistry.java +++ /dev/null @@ -1,1130 +0,0 @@ -package com.minersstudios.mscore.language; - -import net.kyori.adventure.text.TranslatableComponent; -import org.jetbrains.annotations.Contract; - -import static com.minersstudios.mscore.language.LanguageFile.renderTranslation; -import static com.minersstudios.mscore.language.LanguageFile.renderTranslationComponent; - -/** - * This class is storing all keys for translations. It contains three nested - * classes: - *
    - *
  • {@link Keys}
  • - *
  • {@link Components}
  • - *
  • {@link String}
  • - *
- * - * @see LanguageFile - * @see Translations repository - */ -public final class LanguageRegistry { - - @Contract(" -> fail") - private LanguageRegistry() throws AssertionError { - throw new AssertionError("Utility class"); - } - - /** - * This class provides keys for various translations. Each key is a constant - * string, that is used for getting translation from {@link LanguageFile}. - */ - public static final class Keys { - // - public static final String FORMAT_LEAVE_MESSAGE = "ms.format.leave.message"; - public static final String LINK_HOVER = "ms.link.hover"; - public static final String COMMAND_HOVER_SUGGEST = "ms.command.hover.suggest"; - public static final String COMMAND_HOVER_RUN = "ms.command.hover.run"; - public static final String ON_DISABLE_MESSAGE_TITLE = "ms.on_disable.message.title"; - public static final String ON_DISABLE_MESSAGE_SUBTITLE = "ms.on_disable.message.subtitle"; - public static final String SERVER_NOT_FULLY_LOADED_TITLE = "ms.server_not_fully_loaded.title"; - public static final String SERVER_NOT_FULLY_LOADED_SUBTITLE = "ms.server_not_fully_loaded.subtitle"; - public static final String SOMETHING_WENT_WRONG_TITLE = "ms.something_went_wrong.title"; - public static final String SOMETHING_WENT_WRONG_SUBTITLE = "ms.something_went_wrong.subtitle"; - public static final String INFO_PLAYER_FILE_CREATED = "ms.info.player_file_created"; - public static final String INFO_PLAYER_ITEM_REMOVED = "ms.info.player_item_removed"; - public static final String INFO_PLAYER_ADDED_IP = "ms.info.player_added_ip"; - public static final String INFO_PLAYER_DEATH_INFO = "ms.info.player_death_info"; - public static final String WARNING_YOU_CANT_DO_THIS_NOW = "ms.warning.you_cant_do_this_now"; - public static final String ERROR_PLAYER_NOT_ONLINE = "ms.error.player_not_online"; - public static final String ERROR_ID_NOT_FOUND = "ms.error.id_not_found"; - public static final String ERROR_PLAYER_NOT_FOUND = "ms.error.player_not_found"; - public static final String ERROR_SOMETHING_WENT_WRONG = "ms.error.something_went_wrong"; - public static final String ERROR_WRONG_FORMAT = "ms.error.wrong_format"; - public static final String ERROR_ONLY_PLAYER_COMMAND = "ms.error.only_player_command"; - public static final String ERROR_UNKNOWN_COMMAND = "ms.error.unknown_command"; - public static final String ERROR_NO_PERMISSION = "ms.error.no_permission"; - public static final String ERROR_FLYING_PLAYER = "ms.error.flying_player"; - public static final String ERROR_FLYING_VEHICLE = "ms.error.flying_vehicle"; - public static final String ERROR_CONNECTION_THROTTLE = "ms.error.connection_throttle"; - public static final String ERROR_TOO_MANY_PACKETS = "ms.error.too_many_packets"; - public static final String RESOURCE_PACK_ACCEPTED = "ms.resource_pack.accepted"; - public static final String RESOURCE_PACK_DECLINED_CONSOLE = "ms.resource_pack.declined.console"; - public static final String RESOURCE_PACK_DECLINED_RECEIVER_TITLE = "ms.resource_pack.declined.receiver.title"; - public static final String RESOURCE_PACK_DECLINED_RECEIVER_SUBTITLE = "ms.resource_pack.declined.receiver.subtitle"; - public static final String RESOURCE_PACK_SUCCESSFULLY_LOADED = "ms.resource_pack.successfully_loaded"; - public static final String RESOURCE_PACK_FAILED_DOWNLOAD_CONSOLE = "ms.resource_pack.failed_download.console"; - public static final String RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_TITLE = "ms.resource_pack.failed_download.receiver.title"; - public static final String RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_SUBTITLE = "ms.resource_pack.failed_download.receiver.subtitle"; - public static final String BOOK_ANONYMOUS = "ms.book.anonymous"; - public static final String PRE_LOGIN_BANNED_TITLE = "ms.pre_login.banned.title"; - public static final String PRE_LOGIN_BANNED_SUBTITLE = "ms.pre_login.banned.subtitle"; - public static final String PRE_LOGIN_WHITELISTED_TITLE = "ms.pre_login.whitelisted.title"; - public static final String PRE_LOGIN_WHITELISTED_SUBTITLE = "ms.pre_login.whitelisted.subtitle"; - public static final String PRE_LOGIN_TECH_WORKS_TITLE = "ms.pre_login.tech_works.title"; - public static final String PRE_LOGIN_TECH_WORKS_SUBTITLE = "ms.pre_login.tech_works.subtitle"; - public static final String COMMAND_BAN_DEFAULT_REASON = "ms.command.ban.default_reason"; - public static final String COMMAND_BAN_ALREADY_SENDER = "ms.command.ban.already.sender"; - public static final String COMMAND_BAN_MESSAGE_RECEIVER_TITLE = "ms.command.ban.message.receiver.title"; - public static final String COMMAND_BAN_MESSAGE_RECEIVER_SUBTITLE = "ms.command.ban.message.receiver.subtitle"; - public static final String COMMAND_BAN_MESSAGE_SENDER = "ms.command.ban.message.sender"; - public static final String COMMAND_BAN_TIME_FOREVER = "ms.command.ban.time.forever"; - public static final String COMMAND_UNBAN_NOT_BANNED = "ms.command.unban.not_banned"; - public static final String COMMAND_UNBAN_MESSAGE_SENDER = "ms.command.unban.message.sender"; - public static final String COMMAND_MUTE_DEFAULT_REASON = "ms.command.mute.default_reason"; - public static final String COMMAND_MUTE_ALREADY_RECEIVER = "ms.command.mute.already.receiver"; - public static final String COMMAND_MUTE_ALREADY_SENDER = "ms.command.mute.already.sender"; - public static final String COMMAND_MUTE_MESSAGE_RECEIVER = "ms.command.mute.message.receiver"; - public static final String COMMAND_MUTE_MESSAGE_SENDER = "ms.command.mute.message.sender"; - public static final String COMMAND_UNMUTE_NOT_MUTED = "ms.command.unmute.not_muted"; - public static final String COMMAND_UNMUTE_SENDER_MESSAGE = "ms.command.unmute.sender.message"; - public static final String COMMAND_UNMUTE_RECEIVER_MESSAGE = "ms.command.unmute.receiver.message"; - public static final String COMMAND_KICK_DEFAULT_REASON = "ms.command.kick.default_reason"; - public static final String COMMAND_KICK_MESSAGE_RECEIVER_TITLE = "ms.command.kick.message.receiver.title"; - public static final String COMMAND_KICK_MESSAGE_RECEIVER_SUBTITLE = "ms.command.kick.message.receiver.subtitle"; - public static final String COMMAND_KICK_MESSAGE_SENDER = "ms.command.kick.message.sender"; - public static final String COMMAND_WHITE_LIST_RELOAD = "ms.command.white_list.reload"; - public static final String COMMAND_WHITE_LIST_ADD_NICKNAME_WARNING = "ms.command.white_list.add.nickname_warning"; - public static final String COMMAND_WHITE_LIST_ADD_ALREADY = "ms.command.white_list.add.already"; - public static final String COMMAND_WHITE_LIST_ADD_SENDER_MESSAGE = "ms.command.white_list.add.sender.message"; - public static final String COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_TITLE = "ms.command.white_list.remove.receiver.message.title"; - public static final String COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_SUBTITLE = "ms.command.white_list.remove.receiver.message.subtitle"; - public static final String COMMAND_WHITE_LIST_REMOVE_SENDER_MESSAGE = "ms.command.white_list.remove.sender.message"; - public static final String COMMAND_WHITE_LIST_REMOVE_NOT_FOUND = "ms.command.white_list.remove.not_found"; - public static final String COMMAND_SIT_IN_AIR = "ms.command.sit.in_air"; - public static final String COMMAND_TRY_VARIANT_SUCCESS = "ms.command.try.variant.success"; - public static final String COMMAND_TRY_VARIANT_FAIL = "ms.command.try.variant.fail"; - public static final String COMMAND_TELEPORT_TO_LAST_DEATH_NO_POSITION = "ms.command.teleport_to_last_death.no_position"; - public static final String COMMAND_TELEPORT_TO_LAST_DEATH_SENDER_MESSAGE = "ms.command.teleport_to_last_death.sender.message"; - public static final String COMMAND_WORLD_TELEPORT_WORLD_NOT_FOUND = "ms.command.world_teleport.world_not_found"; - public static final String COMMAND_WORLD_TELEPORT_TOO_BIG_COORDINATES = "ms.command.world_teleport.too_big_coordinates"; - public static final String COMMAND_WORLD_TELEPORT_SENDER_MESSAGE = "ms.command.world_teleport.sender.message"; - public static final String COMMAND_GET_MAP_LOCATION_NO_MAP_IN_RIGHT_HAND = "ms.command.get_map_location.no_map_in_right_hand"; - public static final String COMMAND_GET_MAP_LOCATION_FORMAT = "ms.command.get_map_location.format"; - public static final String COMMAND_GET_MAP_LOCATION_COMMAND_BUTTON_TEXT = "ms.command.get_map_location.command_button_text"; - public static final String COMMAND_MSESSENTIALS_RELOAD_SUCCESS = "ms.command.msessentials.reload.success"; - public static final String COMMAND_MSESSENTIALS_UPDATE_IDS_SUCCESS = "ms.command.msessentials.update_ids.success"; - public static final String COMMAND_MSESSENTIALS_UPDATE_MUTES_SUCCESS = "ms.command.msessentials.update_mutes.success"; - public static final String COMMAND_MSCORE_RELOAD_LANGUAGE_SUCCESS = "ms.command.mscore.reload_language.success"; - public static final String COMMAND_MSCORE_RELOAD_CONFIG_SUCCESS = "ms.command.mscore.reload_config.success"; - public static final String COMMAND_PLAYER_UPDATE_SUCCESS = "ms.command.player.update.success"; - public static final String COMMAND_PLAYER_FIRST_JOIN = "ms.command.player.first_join"; - public static final String COMMAND_PLAYER_NAME_ABOUT = "ms.command.player.name.about"; - public static final String COMMAND_PLAYER_NAME_FULL_RESET_SENDER = "ms.command.player.name.full_reset.sender"; - public static final String COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_TITLE = "ms.command.player.name.full_reset.receiver.title"; - public static final String COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_SUBTITLE = "ms.command.player.name.full_reset.receiver.subtitle"; - public static final String COMMAND_PLAYER_NAME_GET_FIRST_NAME = "ms.command.player.name.get.first_name"; - public static final String COMMAND_PLAYER_NAME_GET_LAST_NAME = "ms.command.player.name.get.last_name"; - public static final String COMMAND_PLAYER_NAME_GET_PATRONYMIC = "ms.command.player.name.get.patronymic"; - public static final String COMMAND_PLAYER_NAME_NOW_FULL = "ms.command.player.name.now_full"; - public static final String COMMAND_PLAYER_PRONOUNS_GET = "ms.command.player.pronouns.get"; - public static final String COMMAND_PLAYER_PRONOUNS_SET = "ms.command.player.pronouns.set"; - public static final String COMMAND_PLAYER_PRONOUNS_USE_ONE_OF = "ms.command.player.pronouns.use_one_of"; - public static final String COMMAND_PLAYER_BAN_INFO_INFO = "ms.command.player.ban_info.info"; - public static final String COMMAND_PLAYER_BAN_INFO_INFO_NOT_BANNED = "ms.command.player.ban_info.info_not_banned"; - public static final String COMMAND_PLAYER_BAN_INFO_NOT_BANNED = "ms.command.player.ban_info.not_banned"; - public static final String COMMAND_PLAYER_BAN_INFO_GET_REASON = "ms.command.player.ban_info.get.reason"; - public static final String COMMAND_PLAYER_BAN_INFO_SET_REASON = "ms.command.player.ban_info.set.reason"; - public static final String COMMAND_PLAYER_BAN_INFO_GET_TIME_TO = "ms.command.player.ban_info.get.time_to"; - public static final String COMMAND_PLAYER_BAN_INFO_SET_TIME_TO = "ms.command.player.ban_info.set.time_to"; - public static final String COMMAND_PLAYER_MUTE_INFO_INFO = "ms.command.player.mute_info.info"; - public static final String COMMAND_PLAYER_MUTE_INFO_INFO_NOT_MUTED = "ms.command.player.mute_info.info_not_muted"; - public static final String COMMAND_PLAYER_MUTE_INFO_NOT_MUTED = "ms.command.player.mute_info.not_muted"; - public static final String COMMAND_PLAYER_MUTE_INFO_GET_REASON = "ms.command.player.mute_info.get.reason"; - public static final String COMMAND_PLAYER_MUTE_INFO_SET_REASON = "ms.command.player.mute_info.set.reason"; - public static final String COMMAND_PLAYER_MUTE_INFO_GET_TIME_TO = "ms.command.player.mute_info.get.time_to"; - public static final String COMMAND_PLAYER_MUTE_INFO_SET_TIME_TO = "ms.command.player.mute_info.set.time_to"; - public static final String COMMAND_PLAYER_GAME_PARAMS_USE_ONE_OF = "ms.command.player.game_params.use_one_of"; - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE = "ms.command.player.game_params.get.game_mode"; - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE_FULL = "ms.command.player.game_params.get.game_mode_full"; - public static final String COMMAND_PLAYER_GAME_PARAMS_SET_GAME_MODE = "ms.command.player.game_params.set.game_mode"; - public static final String COMMAND_PLAYER_GAME_PARAMS_GAME_MODE_USE_ONE_OF = "ms.command.player.game_params.game_mode_use_one_of"; - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH = "ms.command.player.game_params.get.health"; - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH_FULL = "ms.command.player.game_params.get.health_full"; - public static final String COMMAND_PLAYER_GAME_PARAMS_SET_HEALTH = "ms.command.player.game_params.set.health"; - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_AIR = "ms.command.player.game_params.get.air"; - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_AIR_FULL = "ms.command.player.game_params.get.air_full"; - public static final String COMMAND_PLAYER_GAME_PARAMS_SET_AIR = "ms.command.player.game_params.set.air"; - public static final String COMMAND_PLAYER_SETTINGS_USE_ONE_OF = "ms.command.player.settings.use_one_of"; - public static final String COMMAND_PLAYER_SETTINGS_GET_RESOURCEPACK_TYPE = "ms.command.player.settings.get.resourcepack_type"; - public static final String COMMAND_PLAYER_SETTINGS_SET_RESOURCEPACK_TYPE = "ms.command.player.settings.set.resourcepack_type"; - public static final String COMMAND_PLAYER_SETTINGS_RESOURCEPACK_TYPE_USE_ONE_OF = "ms.command.player.settings.resourcepack_type_use_one_of"; - public static final String COMMAND_PLAYER_SETTINGS_GET_SKIN = "ms.command.player.settings.get.skin"; - public static final String COMMAND_PLAYER_SETTINGS_GET_NO_SKIN = "ms.command.player.settings.get.no_skin"; - public static final String COMMAND_PLAYER_SETTINGS_SET_SKIN = "ms.command.player.settings.set.skin"; - public static final String COMMAND_PLAYER_SETTINGS_ADD_SKIN = "ms.command.player.settings.add.skin"; - public static final String COMMAND_PLAYER_SETTINGS_ADD_SKIN_ERROR = "ms.command.player.settings.add.skin.error"; - public static final String COMMAND_PLAYER_SETTINGS_REMOVE_SKIN = "ms.command.player.settings.remove.skin"; - public static final String COMMAND_PLAYER_SETTINGS_SKIN_NOT_FOUND = "ms.command.player.settings.skin_not_found"; - public static final String COMMAND_PLAYER_SETTINGS_SKIN_USE_ONE_OF = "ms.command.player.settings.skin.use_one_of"; - public static final String COMMAND_MSBLOCK_GIVE_WRONG_BLOCK = "ms.command.msblock.give.wrong_block"; - public static final String COMMAND_MSBLOCK_GIVE_SUCCESS = "ms.command.msblock.give.success"; - public static final String COMMAND_MSBLOCK_RELOAD_SUCCESS = "ms.command.msblock.reload.success"; - public static final String COMMAND_MSDECOR_GIVE_WRONG_DECOR = "ms.command.msdecor.give.wrong_decor"; - public static final String COMMAND_MSDECOR_GIVE_SUCCESS = "ms.command.msdecor.give.success"; - public static final String COMMAND_MSDECOR_RELOAD_SUCCESS = "ms.command.msdecor.reload.success"; - public static final String COMMAND_MSITEM_GIVE_WRONG_ITEM = "ms.command.msitem.give.wrong_item"; - public static final String COMMAND_MSITEM_GIVE_SUCCESS = "ms.command.msitem.give.success"; - public static final String COMMAND_MSITEM_RELOAD_SUCCESS = "ms.command.msitem.reload.success"; - public static final String COMMAND_DISCORD = "ms.command.discord"; - public static final String COMMAND_DISCORD_LINK_SUCCESS = "ms.command.discord.link.success"; - public static final String COMMAND_DISCORD_UNLINK_NO_LINKS = "ms.command.discord.unlink.no_links"; - public static final String COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS = "ms.command.discord.unlink.minecraft.success"; - public static final String COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS = "ms.command.discord.unlink.discord.success"; - public static final String COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND = "ms.command.set_server_spawn.world_not_found"; - public static final String COMMAND_SET_SERVER_SPAWN_TOO_BIG_COORDINATES = "ms.command.set_server_spawn.too_big_coordinates"; - public static final String COMMAND_SET_SERVER_SPAWN_SUCCESSFULLY_SET = "ms.command.set_server_spawn.successfully_set"; - public static final String DISCORD_SERVER_ENABLED = "ms.discord.server.enabled"; - public static final String DISCORD_SERVER_DISABLED = "ms.discord.server.disabled"; - public static final String DISCORD_BOT_STATUS = "ms.discord.bot.status"; - public static final String DISCORD_NOT_A_USER = "ms.discord.not_a_user"; - public static final String DISCORD_NO_CODE = "ms.discord.no_code"; - public static final String DISCORD_INVALID_CODE = "ms.discord.invalid_code"; - public static final String DISCORD_CODE_ATTEMPTS_LIMIT_REACHED = "ms.discord.code_attempts_limit_reached"; - public static final String DISCORD_MESSAGE_ATTEMPTS_LIMIT_REACHED = "ms.discord.message_attempts_limit_reached"; - public static final String DISCORD_UNKNOWN_COMMAND = "ms.discord.unknown_command"; - public static final String DISCORD_NOT_LINKED = "ms.discord.not_linked"; - public static final String DISCORD_ALREADY_LINKED = "ms.discord.already_linked"; - public static final String DISCORD_SUCCESSFULLY_LINKED = "ms.discord.successfully_linked"; - public static final String DISCORD_BANNED = "ms.discord.banned"; - public static final String DISCORD_UNBANNED = "ms.discord.unbanned"; - public static final String DISCORD_MUTED = "ms.discord.muted"; - public static final String DISCORD_UNMUTED = "ms.discord.unmuted"; - public static final String DISCORD_EMBED_TITLE = "ms.discord.embed.title"; - public static final String DISCORD_SKIN_SERVICE_UNAVAILABLE = "ms.discord.skin.service_unavailable"; - public static final String DISCORD_SKIN_ONLY_ONE_IMG = "ms.discord.skin.only_one_img"; - public static final String DISCORD_SKIN_INVALID_IMG = "ms.discord.skin.invalid_img"; - public static final String DISCORD_SKIN_TOO_MANY_SKINS = "ms.discord.skin.too_many_skins"; - public static final String DISCORD_SKIN_ALREADY_SET = "ms.discord.skin.already_set"; - public static final String DISCORD_SKIN_VARIANT_YES = "ms.discord.skin.variant.yes"; - public static final String DISCORD_SKIN_VARIANT_NO = "ms.discord.skin.variant.no"; - public static final String DISCORD_SKIN_VARIANT_NO_REPLY = "ms.discord.skin.variant.no.reply"; - public static final String DISCORD_SKIN_INVALID_NAME_REGEX = "ms.discord.skin.invalid_name_regex"; - public static final String DISCORD_SKIN_NO_NAME = "ms.discord.skin.no_name"; - public static final String DISCORD_SKIN_LIST_OF_SKINS = "ms.discord.skin.list_of_skins"; - public static final String DISCORD_SKIN_LIST_OF_SKIN_ACTIONS = "ms.discord.skin.list_of_skin_actions"; - public static final String DISCORD_SKIN_ACTION_EDIT_INFO = "ms.discord.skin.action.edit.info"; - public static final String DISCORD_SKIN_ACTION_RENAME_INFO = "ms.discord.skin.action.rename.info"; - public static final String DISCORD_SKIN_INVALID_INDEX = "ms.discord.skin.invalid_index"; - public static final String DISCORD_SKIN_SUCCESSFULLY_ADDED = "ms.discord.skin.successfully_added"; - public static final String DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT = "ms.discord.skin.successfully_added.minecraft"; - public static final String DISCORD_SKIN_EDIT_ALREADY_SET = "ms.discord.skin.edit.already_set"; - public static final String DISCORD_SKIN_SUCCESSFULLY_EDITED = "ms.discord.skin.successfully_edited"; - public static final String DISCORD_SKIN_SUCCESSFULLY_EDITED_MINECRAFT = "ms.discord.skin.successfully_edited.minecraft"; - public static final String DISCORD_SKIN_SUCCESSFULLY_REMOVED = "ms.discord.skin.successfully_removed"; - public static final String DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT = "ms.discord.skin.successfully_removed.minecraft"; - public static final String DISCORD_SKIN_SUCCESSFULLY_RENAMED = "ms.discord.skin.successfully_renamed"; - public static final String DISCORD_SKIN_SUCCESSFULLY_RENAMED_MINECRAFT = "ms.discord.skin.successfully_renamed.minecraft"; - public static final String DISCORD_COMMAND_LIST_OF_SKINS = "ms.discord.command.list_of_skins"; - public static final String DISCORD_COMMAND_SKIN_NOT_FOUND = "ms.discord.command.skin_not_found"; - public static final String DISCORD_COMMAND_INVALID_ARGUMENTS = "ms.discord.command.invalid_arguments"; - public static final String MENU_SKINS_TITLE = "ms.menu.skins.title"; - public static final String MENU_SKINS_BUTTON_APPLY = "ms.menu.skins.button.apply"; - public static final String MENU_SKINS_BUTTON_DELETE = "ms.menu.skins.button.delete"; - public static final String MENU_SKINS_BUTTON_QUIT = "ms.menu.skins.button.quit"; - public static final String MENU_DISCORD_TITLE = "ms.menu.discord.title"; - public static final String MENU_DISCORD_NUMBERS_0 = "ms.menu.discord.numbers.0"; - public static final String MENU_DISCORD_NUMBERS_1 = "ms.menu.discord.numbers.1"; - public static final String MENU_DISCORD_NUMBERS_2 = "ms.menu.discord.numbers.2"; - public static final String MENU_DISCORD_NUMBERS_3 = "ms.menu.discord.numbers.3"; - public static final String MENU_DISCORD_NUMBERS_4 = "ms.menu.discord.numbers.4"; - public static final String MENU_DISCORD_NUMBERS_5 = "ms.menu.discord.numbers.5"; - public static final String MENU_DISCORD_NUMBERS_6 = "ms.menu.discord.numbers.6"; - public static final String MENU_DISCORD_NUMBERS_7 = "ms.menu.discord.numbers.7"; - public static final String MENU_DISCORD_NUMBERS_8 = "ms.menu.discord.numbers.8"; - public static final String MENU_DISCORD_NUMBERS_9 = "ms.menu.discord.numbers.9"; - public static final String MENU_CRAFTS_CATEGORIES_TITLE = "ms.menu.crafts.categories.title"; - public static final String MENU_CRAFTS_CATEGORY_TITLE = "ms.menu.crafts.category.title"; - public static final String MENU_CRAFTS_CRAFT_TITLE = "ms.menu.crafts.craft.title"; - public static final String MENU_CRAFTS_BUTTON_PREVIOUS_PAGE = "ms.menu.crafts.button.previous_page"; - public static final String MENU_CRAFTS_BUTTON_NEXT_PAGE = "ms.menu.crafts.button.next_page"; - public static final String MENU_PRONOUNS_TITLE = "ms.menu.pronouns.title"; - public static final String MENU_PRONOUNS_BUTTON_HE_TITLE = "ms.menu.pronouns.button.he.title"; - public static final String MENU_PRONOUNS_BUTTON_HE_LORE = "ms.menu.pronouns.button.he.lore"; - public static final String MENU_PRONOUNS_BUTTON_SHE_TITLE = "ms.menu.pronouns.button.she.title"; - public static final String MENU_PRONOUNS_BUTTON_SHE_LORE = "ms.menu.pronouns.button.she.lore"; - public static final String MENU_PRONOUNS_BUTTON_THEY_TITLE = "ms.menu.pronouns.button.they.title"; - public static final String MENU_PRONOUNS_BUTTON_THEY_LORE = "ms.menu.pronouns.button.they.lore"; - public static final String MENU_RESOURCE_PACK_TITLE = "ms.menu.resource_pack.title"; - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_TITLE = "ms.menu.resource_pack.button.info.title"; - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_LORE_0 = "ms.menu.resource_pack.button.info.lore.0"; - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_LORE_1 = "ms.menu.resource_pack.button.info.lore.1"; - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_LORE_2 = "ms.menu.resource_pack.button.info.lore.2"; - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_LORE_3 = "ms.menu.resource_pack.button.info.lore.3"; - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_LORE_4 = "ms.menu.resource_pack.button.info.lore.4"; - public static final String MENU_RESOURCE_PACK_BUTTON_NONE_TITLE = "ms.menu.resource_pack.button.none.title"; - public static final String MENU_RESOURCE_PACK_BUTTON_NONE_LORE_0 = "ms.menu.resource_pack.button.none.lore.0"; - public static final String MENU_RESOURCE_PACK_BUTTON_NONE_LORE_1 = "ms.menu.resource_pack.button.none.lore.1"; - public static final String MENU_RESOURCE_PACK_BUTTON_NONE_KICK_TITLE = "ms.menu.resource_pack.button.none.kick.title"; - public static final String MENU_RESOURCE_PACK_BUTTON_NONE_KICK_SUBTITLE = "ms.menu.resource_pack.button.none.kick.subtitle"; - public static final String MENU_RESOURCE_PACK_BUTTON_LITE_TITLE = "ms.menu.resource_pack.button.lite.title"; - public static final String MENU_RESOURCE_PACK_BUTTON_LITE_LORE_0 = "ms.menu.resource_pack.button.lite.lore.0"; - public static final String MENU_RESOURCE_PACK_BUTTON_LITE_LORE_1 = "ms.menu.resource_pack.button.lite.lore.1"; - public static final String MENU_RESOURCE_PACK_BUTTON_LITE_LORE_2 = "ms.menu.resource_pack.button.lite.lore.2"; - public static final String MENU_RESOURCE_PACK_BUTTON_LITE_LORE_3 = "ms.menu.resource_pack.button.lite.lore.3"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_TITLE = "ms.menu.resource_pack.button.full.title"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_0 = "ms.menu.resource_pack.button.full.lore.0"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_1 = "ms.menu.resource_pack.button.full.lore.1"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_2 = "ms.menu.resource_pack.button.full.lore.2"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_3 = "ms.menu.resource_pack.button.full.lore.3"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_4 = "ms.menu.resource_pack.button.full.lore.4"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_5 = "ms.menu.resource_pack.button.full.lore.5"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_6 = "ms.menu.resource_pack.button.full.lore.6"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_7 = "ms.menu.resource_pack.button.full.lore.7"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_8 = "ms.menu.resource_pack.button.full.lore.8"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_9 = "ms.menu.resource_pack.button.full.lore.9"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_10 = "ms.menu.resource_pack.button.full.lore.10"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_11 = "ms.menu.resource_pack.button.full.lore.11"; - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_12 = "ms.menu.resource_pack.button.full.lore.12"; - public static final String MENU_RENAMES_TITLE = "ms.menu.renames.title"; - public static final String MENU_RENAMES_BUTTON_PREVIOUS_PAGE = "ms.menu.renames.button.previous_page"; - public static final String MENU_RENAMES_BUTTON_NEXT_PAGE = "ms.menu.renames.button.next_page"; - public static final String MENU_RENAME_TITLE = "ms.menu.rename.title"; - public static final String MENU_RENAME_NO_EXP = "ms.menu.rename.no_exp"; - public static final String REGISTRATION_ANONYMOUS_NAME = "ms.registration.anonymous.name"; - public static final String REGISTRATION_ONLY_CYRILLIC = "ms.registration.only_cyrillic"; - public static final String REGISTRATION_SIGN_FIRST_NAME_0 = "ms.registration.sign.first_name.0"; - public static final String REGISTRATION_SIGN_FIRST_NAME_1 = "ms.registration.sign.first_name.1"; - public static final String REGISTRATION_SIGN_FIRST_NAME_2 = "ms.registration.sign.first_name.2"; - public static final String REGISTRATION_SIGN_FIRST_NAME_3 = "ms.registration.sign.first_name.3"; - public static final String REGISTRATION_SIGN_LAST_NAME_0 = "ms.registration.sign.last_name.0"; - public static final String REGISTRATION_SIGN_LAST_NAME_1 = "ms.registration.sign.last_name.1"; - public static final String REGISTRATION_SIGN_LAST_NAME_2 = "ms.registration.sign.last_name.2"; - public static final String REGISTRATION_SIGN_LAST_NAME_3 = "ms.registration.sign.last_name.3"; - public static final String REGISTRATION_SIGN_PATRONYMIC_0 = "ms.registration.sign.patronymic.0"; - public static final String REGISTRATION_SIGN_PATRONYMIC_1 = "ms.registration.sign.patronymic.1"; - public static final String REGISTRATION_SIGN_PATRONYMIC_2 = "ms.registration.sign.patronymic.2"; - public static final String REGISTRATION_SIGN_PATRONYMIC_3 = "ms.registration.sign.patronymic.3"; - public static final String REGISTRATION_MESSAGE_0 = "ms.registration.message.0"; - public static final String REGISTRATION_MESSAGE_1 = "ms.registration.message.1"; - public static final String REGISTRATION_MESSAGE_2 = "ms.registration.message.2"; - public static final String REGISTRATION_MESSAGE_3 = "ms.registration.message.3"; - public static final String REGISTRATION_MESSAGE_4 = "ms.registration.message.4"; - public static final String REGISTRATION_MESSAGE_5 = "ms.registration.message.5"; - public static final String REGISTRATION_MESSAGE_6 = "ms.registration.message.6"; - public static final String REGISTRATION_MESSAGE_7 = "ms.registration.message.7"; - public static final String REGISTRATION_MESSAGE_8 = "ms.registration.message.8"; - public static final String REGISTRATION_MESSAGE_9 = "ms.registration.message.9"; - public static final String REGISTRATION_MESSAGE_10 = "ms.registration.message.10"; - public static final String REGISTRATION_MESSAGE_11 = "ms.registration.message.11"; - public static final String REGISTRATION_MESSAGE_12 = "ms.registration.message.12"; - public static final String REGISTRATION_MESSAGE_13 = "ms.registration.message.13"; - public static final String REGISTRATION_MESSAGE_14 = "ms.registration.message.14"; - public static final String REGISTRATION_MESSAGE_15 = "ms.registration.message.15"; - public static final String REGISTRATION_MESSAGE_16 = "ms.registration.message.16"; - public static final String REGISTRATION_MESSAGE_17 = "ms.registration.message.17"; - public static final String CHAT_HOVER_NAME = "ms.chat.hover_name"; - public static final String CHAT_HOVER_MESSAGE = "ms.chat.hover_message"; - public static final String CHAT_LOCAL_FORMAT = "ms.chat.local.format"; - public static final String CHAT_GLOBAL_FORMAT = "ms.chat.global.format"; - public static final String CHAT_PRIVATE_FORMAT_GLOBAL = "ms.chat.private.format.global"; - public static final String CHAT_PRIVATE_FORMAT_SENDER = "ms.chat.private.format.sender"; - public static final String CHAT_PRIVATE_FORMAT_RECEIVER = "ms.chat.private.format.receiver"; - public static final String CHAT_DISCORD_FORMAT = "ms.chat.discord.format"; - public static final String CHAT_DISCORD_FORMAT_REPLYING = "ms.chat.discord.format.replying"; - public static final String CHAT_DISCORD_FORMAT_GLOBAL_TO_LOCAL = "ms.chat.discord.format.global_to_local"; - public static final String CHAT_DISCORD_FORMAT_GLOBAL_TO_GLOBAL = "ms.chat.discord.format.global_to_global"; - public static final String CHAT_DISCORD_ATTACHMENT = "ms.chat.discord.attachment"; - public static final String CHAT_DISCORD_ATTACHMENTS = "ms.chat.discord.attachments"; - public static final String CHAT_ME_FORMAT = "ms.chat.me.format"; - public static final String CHAT_DO_FORMAT = "ms.chat.do.format"; - public static final String CHAT_IT_FORMAT = "ms.chat.it.format"; - public static final String CHAT_TO_DO_FORMAT = "ms.chat.to_do.format"; - public static final String CHAT_TRY_FORMAT = "ms.chat.try.format"; - public static final String CHAT_DEATH_FORMAT_UNO = "ms.chat.death.format.uno"; - public static final String CHAT_DEATH_FORMAT_DUO = "ms.chat.death.format.duo"; - public static final String CHAT_JOIN_FORMAT = "ms.chat.join.format"; - public static final String CHAT_QUIT_FORMAT = "ms.chat.quit.format"; - public static final String PLAYER_NAME_NICKNAME = "ms.player.name.nickname"; - public static final String PLAYER_NAME_FIRST_NAME = "ms.player.name.first_name"; - public static final String PLAYER_NAME_LAST_NAME = "ms.player.name.last_name"; - public static final String PLAYER_NAME_PATRONYMIC = "ms.player.name.patronymic"; - public static final String PLAYER_PRONOUNS_HE_JOIN = "ms.player.pronouns.he.join"; - public static final String PLAYER_PRONOUNS_HE_QUIT = "ms.player.pronouns.he.quit"; - public static final String PLAYER_PRONOUNS_HE_SPIT = "ms.player.pronouns.he.spit"; - public static final String PLAYER_PRONOUNS_HE_FART = "ms.player.pronouns.he.fart"; - public static final String PLAYER_PRONOUNS_HE_PRONOUNS = "ms.player.pronouns.he.pronouns"; - public static final String PLAYER_PRONOUNS_HE_TRAVELER = "ms.player.pronouns.he.traveler"; - public static final String PLAYER_PRONOUNS_HE_SIT = "ms.player.pronouns.he.sit"; - public static final String PLAYER_PRONOUNS_HE_GET_UP = "ms.player.pronouns.he.get_up"; - public static final String PLAYER_PRONOUNS_HE_DEATH = "ms.player.pronouns.he.death"; - public static final String PLAYER_PRONOUNS_HE_KILL = "ms.player.pronouns.he.kill"; - public static final String PLAYER_PRONOUNS_HE_SAID = "ms.player.pronouns.he.said"; - public static final String PLAYER_PRONOUNS_SHE_JOIN = "ms.player.pronouns.she.join"; - public static final String PLAYER_PRONOUNS_SHE_QUIT = "ms.player.pronouns.she.quit"; - public static final String PLAYER_PRONOUNS_SHE_SPIT = "ms.player.pronouns.she.spit"; - public static final String PLAYER_PRONOUNS_SHE_FART = "ms.player.pronouns.she.fart"; - public static final String PLAYER_PRONOUNS_SHE_PRONOUNS = "ms.player.pronouns.she.pronouns"; - public static final String PLAYER_PRONOUNS_SHE_TRAVELER = "ms.player.pronouns.she.traveler"; - public static final String PLAYER_PRONOUNS_SHE_SIT = "ms.player.pronouns.she.sit"; - public static final String PLAYER_PRONOUNS_SHE_GET_UP = "ms.player.pronouns.she.get_up"; - public static final String PLAYER_PRONOUNS_SHE_DEATH = "ms.player.pronouns.she.death"; - public static final String PLAYER_PRONOUNS_SHE_KILL = "ms.player.pronouns.she.kill"; - public static final String PLAYER_PRONOUNS_SHE_SAID = "ms.player.pronouns.she.said"; - public static final String PLAYER_PRONOUNS_THEY_JOIN = "ms.player.pronouns.they.join"; - public static final String PLAYER_PRONOUNS_THEY_QUIT = "ms.player.pronouns.they.quit"; - public static final String PLAYER_PRONOUNS_THEY_SPIT = "ms.player.pronouns.they.spit"; - public static final String PLAYER_PRONOUNS_THEY_FART = "ms.player.pronouns.they.fart"; - public static final String PLAYER_PRONOUNS_THEY_PRONOUNS = "ms.player.pronouns.they.pronouns"; - public static final String PLAYER_PRONOUNS_THEY_TRAVELER = "ms.player.pronouns.they.traveler"; - public static final String PLAYER_PRONOUNS_THEY_SIT = "ms.player.pronouns.they.sit"; - public static final String PLAYER_PRONOUNS_THEY_GET_UP = "ms.player.pronouns.they.get_up"; - public static final String PLAYER_PRONOUNS_THEY_DEATH = "ms.player.pronouns.they.death"; - public static final String PLAYER_PRONOUNS_THEY_KILL = "ms.player.pronouns.they.kill"; - public static final String PLAYER_PRONOUNS_THEY_SAID = "ms.player.pronouns.they.said"; - // - - @Contract(" -> fail") - private Keys() throws AssertionError { - throw new AssertionError("Utility class"); - } - } - - /** - * This class provides translatable components for various messages. Each - * component is created using a key and a method for rendering a component. - * All keys are obtained from the {@link Keys} class. - * - * @see Keys - * @see LanguageFile#renderTranslationComponent(String) - */ - public static final class Components { - // - public static final TranslatableComponent FORMAT_LEAVE_MESSAGE = renderTranslationComponent(Keys.FORMAT_LEAVE_MESSAGE); - public static final TranslatableComponent LINK_HOVER = renderTranslationComponent(Keys.LINK_HOVER); - public static final TranslatableComponent COMMAND_HOVER_SUGGEST = renderTranslationComponent(Keys.COMMAND_HOVER_SUGGEST); - public static final TranslatableComponent COMMAND_HOVER_RUN = renderTranslationComponent(Keys.COMMAND_HOVER_RUN); - public static final TranslatableComponent ON_DISABLE_MESSAGE_TITLE = renderTranslationComponent(Keys.ON_DISABLE_MESSAGE_TITLE); - public static final TranslatableComponent ON_DISABLE_MESSAGE_SUBTITLE = renderTranslationComponent(Keys.ON_DISABLE_MESSAGE_SUBTITLE); - public static final TranslatableComponent SERVER_NOT_FULLY_LOADED_TITLE = renderTranslationComponent(Keys.SERVER_NOT_FULLY_LOADED_TITLE); - public static final TranslatableComponent SERVER_NOT_FULLY_LOADED_SUBTITLE = renderTranslationComponent(Keys.SERVER_NOT_FULLY_LOADED_SUBTITLE); - public static final TranslatableComponent SOMETHING_WENT_WRONG_TITLE = renderTranslationComponent(Keys.SOMETHING_WENT_WRONG_TITLE); - public static final TranslatableComponent SOMETHING_WENT_WRONG_SUBTITLE = renderTranslationComponent(Keys.SOMETHING_WENT_WRONG_SUBTITLE); - public static final TranslatableComponent INFO_PLAYER_FILE_CREATED = renderTranslationComponent(Keys.INFO_PLAYER_FILE_CREATED); - public static final TranslatableComponent INFO_PLAYER_ITEM_REMOVED = renderTranslationComponent(Keys.INFO_PLAYER_ITEM_REMOVED); - public static final TranslatableComponent INFO_PLAYER_ADDED_IP = renderTranslationComponent(Keys.INFO_PLAYER_ADDED_IP); - public static final TranslatableComponent INFO_PLAYER_DEATH_INFO = renderTranslationComponent(Keys.INFO_PLAYER_DEATH_INFO); - public static final TranslatableComponent WARNING_YOU_CANT_DO_THIS_NOW = renderTranslationComponent(Keys.WARNING_YOU_CANT_DO_THIS_NOW); - public static final TranslatableComponent ERROR_PLAYER_NOT_ONLINE = renderTranslationComponent(Keys.ERROR_PLAYER_NOT_ONLINE); - public static final TranslatableComponent ERROR_ID_NOT_FOUND = renderTranslationComponent(Keys.ERROR_ID_NOT_FOUND); - public static final TranslatableComponent ERROR_PLAYER_NOT_FOUND = renderTranslationComponent(Keys.ERROR_PLAYER_NOT_FOUND); - public static final TranslatableComponent ERROR_SOMETHING_WENT_WRONG = renderTranslationComponent(Keys.ERROR_SOMETHING_WENT_WRONG); - public static final TranslatableComponent ERROR_WRONG_FORMAT = renderTranslationComponent(Keys.ERROR_WRONG_FORMAT); - public static final TranslatableComponent ERROR_ONLY_PLAYER_COMMAND = renderTranslationComponent(Keys.ERROR_ONLY_PLAYER_COMMAND); - public static final TranslatableComponent ERROR_UNKNOWN_COMMAND = renderTranslationComponent(Keys.ERROR_UNKNOWN_COMMAND); - public static final TranslatableComponent ERROR_NO_PERMISSION = renderTranslationComponent(Keys.ERROR_NO_PERMISSION); - public static final TranslatableComponent ERROR_FLYING_PLAYER = renderTranslationComponent(Keys.ERROR_FLYING_PLAYER); - public static final TranslatableComponent ERROR_FLYING_VEHICLE = renderTranslationComponent(Keys.ERROR_FLYING_VEHICLE); - public static final TranslatableComponent ERROR_CONNECTION_THROTTLE = renderTranslationComponent(Keys.ERROR_CONNECTION_THROTTLE); - public static final TranslatableComponent ERROR_TOO_MANY_PACKETS = renderTranslationComponent(Keys.ERROR_TOO_MANY_PACKETS); - public static final TranslatableComponent RESOURCE_PACK_ACCEPTED = renderTranslationComponent(Keys.RESOURCE_PACK_ACCEPTED); - public static final TranslatableComponent RESOURCE_PACK_DECLINED_CONSOLE = renderTranslationComponent(Keys.RESOURCE_PACK_DECLINED_CONSOLE); - public static final TranslatableComponent RESOURCE_PACK_DECLINED_RECEIVER_TITLE = renderTranslationComponent(Keys.RESOURCE_PACK_DECLINED_RECEIVER_TITLE); - public static final TranslatableComponent RESOURCE_PACK_DECLINED_RECEIVER_SUBTITLE = renderTranslationComponent(Keys.RESOURCE_PACK_DECLINED_RECEIVER_SUBTITLE); - public static final TranslatableComponent RESOURCE_PACK_SUCCESSFULLY_LOADED = renderTranslationComponent(Keys.RESOURCE_PACK_SUCCESSFULLY_LOADED); - public static final TranslatableComponent RESOURCE_PACK_FAILED_DOWNLOAD_CONSOLE = renderTranslationComponent(Keys.RESOURCE_PACK_FAILED_DOWNLOAD_CONSOLE); - public static final TranslatableComponent RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_TITLE = renderTranslationComponent(Keys.RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_TITLE); - public static final TranslatableComponent RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_SUBTITLE = renderTranslationComponent(Keys.RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_SUBTITLE); - public static final TranslatableComponent BOOK_ANONYMOUS = renderTranslationComponent(Keys.BOOK_ANONYMOUS); - public static final TranslatableComponent PRE_LOGIN_BANNED_TITLE = renderTranslationComponent(Keys.PRE_LOGIN_BANNED_TITLE); - public static final TranslatableComponent PRE_LOGIN_BANNED_SUBTITLE = renderTranslationComponent(Keys.PRE_LOGIN_BANNED_SUBTITLE); - public static final TranslatableComponent PRE_LOGIN_WHITELISTED_TITLE = renderTranslationComponent(Keys.PRE_LOGIN_WHITELISTED_TITLE); - public static final TranslatableComponent PRE_LOGIN_WHITELISTED_SUBTITLE = renderTranslationComponent(Keys.PRE_LOGIN_WHITELISTED_SUBTITLE); - public static final TranslatableComponent PRE_LOGIN_TECH_WORKS_TITLE = renderTranslationComponent(Keys.PRE_LOGIN_TECH_WORKS_TITLE); - public static final TranslatableComponent PRE_LOGIN_TECH_WORKS_SUBTITLE = renderTranslationComponent(Keys.PRE_LOGIN_TECH_WORKS_SUBTITLE); - public static final TranslatableComponent COMMAND_BAN_DEFAULT_REASON = renderTranslationComponent(Keys.COMMAND_BAN_DEFAULT_REASON); - public static final TranslatableComponent COMMAND_BAN_ALREADY_SENDER = renderTranslationComponent(Keys.COMMAND_BAN_ALREADY_SENDER); - public static final TranslatableComponent COMMAND_BAN_MESSAGE_RECEIVER_TITLE = renderTranslationComponent(Keys.COMMAND_BAN_MESSAGE_RECEIVER_TITLE); - public static final TranslatableComponent COMMAND_BAN_MESSAGE_RECEIVER_SUBTITLE = renderTranslationComponent(Keys.COMMAND_BAN_MESSAGE_RECEIVER_SUBTITLE); - public static final TranslatableComponent COMMAND_BAN_MESSAGE_SENDER = renderTranslationComponent(Keys.COMMAND_BAN_MESSAGE_SENDER); - public static final TranslatableComponent COMMAND_BAN_TIME_FOREVER = renderTranslationComponent(Keys.COMMAND_BAN_TIME_FOREVER); - public static final TranslatableComponent COMMAND_UNBAN_NOT_BANNED = renderTranslationComponent(Keys.COMMAND_UNBAN_NOT_BANNED); - public static final TranslatableComponent COMMAND_UNBAN_MESSAGE_SENDER = renderTranslationComponent(Keys.COMMAND_UNBAN_MESSAGE_SENDER); - public static final TranslatableComponent COMMAND_MUTE_DEFAULT_REASON = renderTranslationComponent(Keys.COMMAND_MUTE_DEFAULT_REASON); - public static final TranslatableComponent COMMAND_MUTE_ALREADY_RECEIVER = renderTranslationComponent(Keys.COMMAND_MUTE_ALREADY_RECEIVER); - public static final TranslatableComponent COMMAND_MUTE_ALREADY_SENDER = renderTranslationComponent(Keys.COMMAND_MUTE_ALREADY_SENDER); - public static final TranslatableComponent COMMAND_MUTE_MESSAGE_RECEIVER = renderTranslationComponent(Keys.COMMAND_MUTE_MESSAGE_RECEIVER); - public static final TranslatableComponent COMMAND_MUTE_MESSAGE_SENDER = renderTranslationComponent(Keys.COMMAND_MUTE_MESSAGE_SENDER); - public static final TranslatableComponent COMMAND_UNMUTE_NOT_MUTED = renderTranslationComponent(Keys.COMMAND_UNMUTE_NOT_MUTED); - public static final TranslatableComponent COMMAND_UNMUTE_SENDER_MESSAGE = renderTranslationComponent(Keys.COMMAND_UNMUTE_SENDER_MESSAGE); - public static final TranslatableComponent COMMAND_UNMUTE_RECEIVER_MESSAGE = renderTranslationComponent(Keys.COMMAND_UNMUTE_RECEIVER_MESSAGE); - public static final TranslatableComponent COMMAND_KICK_DEFAULT_REASON = renderTranslationComponent(Keys.COMMAND_KICK_DEFAULT_REASON); - public static final TranslatableComponent COMMAND_KICK_MESSAGE_RECEIVER_TITLE = renderTranslationComponent(Keys.COMMAND_KICK_MESSAGE_RECEIVER_TITLE); - public static final TranslatableComponent COMMAND_KICK_MESSAGE_RECEIVER_SUBTITLE = renderTranslationComponent(Keys.COMMAND_KICK_MESSAGE_RECEIVER_SUBTITLE); - public static final TranslatableComponent COMMAND_KICK_MESSAGE_SENDER = renderTranslationComponent(Keys.COMMAND_KICK_MESSAGE_SENDER); - public static final TranslatableComponent COMMAND_WHITE_LIST_RELOAD = renderTranslationComponent(Keys.COMMAND_WHITE_LIST_RELOAD); - public static final TranslatableComponent COMMAND_WHITE_LIST_ADD_NICKNAME_WARNING = renderTranslationComponent(Keys.COMMAND_WHITE_LIST_ADD_NICKNAME_WARNING); - public static final TranslatableComponent COMMAND_WHITE_LIST_ADD_ALREADY = renderTranslationComponent(Keys.COMMAND_WHITE_LIST_ADD_ALREADY); - public static final TranslatableComponent COMMAND_WHITE_LIST_ADD_SENDER_MESSAGE = renderTranslationComponent(Keys.COMMAND_WHITE_LIST_ADD_SENDER_MESSAGE); - public static final TranslatableComponent COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_TITLE = renderTranslationComponent(Keys.COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_TITLE); - public static final TranslatableComponent COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_SUBTITLE = renderTranslationComponent(Keys.COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_SUBTITLE); - public static final TranslatableComponent COMMAND_WHITE_LIST_REMOVE_SENDER_MESSAGE = renderTranslationComponent(Keys.COMMAND_WHITE_LIST_REMOVE_SENDER_MESSAGE); - public static final TranslatableComponent COMMAND_WHITE_LIST_REMOVE_NOT_FOUND = renderTranslationComponent(Keys.COMMAND_WHITE_LIST_REMOVE_NOT_FOUND); - public static final TranslatableComponent COMMAND_SIT_IN_AIR = renderTranslationComponent(Keys.COMMAND_SIT_IN_AIR); - public static final TranslatableComponent COMMAND_TRY_VARIANT_SUCCESS = renderTranslationComponent(Keys.COMMAND_TRY_VARIANT_SUCCESS); - public static final TranslatableComponent COMMAND_TRY_VARIANT_FAIL = renderTranslationComponent(Keys.COMMAND_TRY_VARIANT_FAIL); - public static final TranslatableComponent COMMAND_TELEPORT_TO_LAST_DEATH_NO_POSITION = renderTranslationComponent(Keys.COMMAND_TELEPORT_TO_LAST_DEATH_NO_POSITION); - public static final TranslatableComponent COMMAND_TELEPORT_TO_LAST_DEATH_SENDER_MESSAGE = renderTranslationComponent(Keys.COMMAND_TELEPORT_TO_LAST_DEATH_SENDER_MESSAGE); - public static final TranslatableComponent COMMAND_WORLD_TELEPORT_WORLD_NOT_FOUND = renderTranslationComponent(Keys.COMMAND_WORLD_TELEPORT_WORLD_NOT_FOUND); - public static final TranslatableComponent COMMAND_WORLD_TELEPORT_TOO_BIG_COORDINATES = renderTranslationComponent(Keys.COMMAND_WORLD_TELEPORT_TOO_BIG_COORDINATES); - public static final TranslatableComponent COMMAND_WORLD_TELEPORT_SENDER_MESSAGE = renderTranslationComponent(Keys.COMMAND_WORLD_TELEPORT_SENDER_MESSAGE); - public static final TranslatableComponent COMMAND_GET_MAP_LOCATION_NO_MAP_IN_RIGHT_HAND = renderTranslationComponent(Keys.COMMAND_GET_MAP_LOCATION_NO_MAP_IN_RIGHT_HAND); - public static final TranslatableComponent COMMAND_GET_MAP_LOCATION_FORMAT = renderTranslationComponent(Keys.COMMAND_GET_MAP_LOCATION_FORMAT); - public static final TranslatableComponent COMMAND_GET_MAP_LOCATION_COMMAND_BUTTON_TEXT = renderTranslationComponent(Keys.COMMAND_GET_MAP_LOCATION_COMMAND_BUTTON_TEXT); - public static final TranslatableComponent COMMAND_MSESSENTIALS_RELOAD_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSESSENTIALS_RELOAD_SUCCESS); - public static final TranslatableComponent COMMAND_MSESSENTIALS_UPDATE_IDS_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSESSENTIALS_UPDATE_IDS_SUCCESS); - public static final TranslatableComponent COMMAND_MSESSENTIALS_UPDATE_MUTES_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSESSENTIALS_UPDATE_MUTES_SUCCESS); - public static final TranslatableComponent COMMAND_MSCORE_RELOAD_LANGUAGE_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSCORE_RELOAD_LANGUAGE_SUCCESS); - public static final TranslatableComponent COMMAND_MSCORE_RELOAD_CONFIG_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSCORE_RELOAD_CONFIG_SUCCESS); - public static final TranslatableComponent COMMAND_PLAYER_UPDATE_SUCCESS = renderTranslationComponent(Keys.COMMAND_PLAYER_UPDATE_SUCCESS); - public static final TranslatableComponent COMMAND_PLAYER_FIRST_JOIN = renderTranslationComponent(Keys.COMMAND_PLAYER_FIRST_JOIN); - public static final TranslatableComponent COMMAND_PLAYER_NAME_ABOUT = renderTranslationComponent(Keys.COMMAND_PLAYER_NAME_ABOUT); - public static final TranslatableComponent COMMAND_PLAYER_NAME_FULL_RESET_SENDER = renderTranslationComponent(Keys.COMMAND_PLAYER_NAME_FULL_RESET_SENDER); - public static final TranslatableComponent COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_TITLE = renderTranslationComponent(Keys.COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_TITLE); - public static final TranslatableComponent COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_SUBTITLE = renderTranslationComponent(Keys.COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_SUBTITLE); - public static final TranslatableComponent COMMAND_PLAYER_NAME_GET_FIRST_NAME = renderTranslationComponent(Keys.COMMAND_PLAYER_NAME_GET_FIRST_NAME); - public static final TranslatableComponent COMMAND_PLAYER_NAME_GET_LAST_NAME = renderTranslationComponent(Keys.COMMAND_PLAYER_NAME_GET_LAST_NAME); - public static final TranslatableComponent COMMAND_PLAYER_NAME_GET_PATRONYMIC = renderTranslationComponent(Keys.COMMAND_PLAYER_NAME_GET_PATRONYMIC); - public static final TranslatableComponent COMMAND_PLAYER_NAME_NOW_FULL = renderTranslationComponent(Keys.COMMAND_PLAYER_NAME_NOW_FULL); - public static final TranslatableComponent COMMAND_PLAYER_PRONOUNS_GET = renderTranslationComponent(Keys.COMMAND_PLAYER_PRONOUNS_GET); - public static final TranslatableComponent COMMAND_PLAYER_PRONOUNS_SET = renderTranslationComponent(Keys.COMMAND_PLAYER_PRONOUNS_SET); - public static final TranslatableComponent COMMAND_PLAYER_PRONOUNS_USE_ONE_OF = renderTranslationComponent(Keys.COMMAND_PLAYER_PRONOUNS_USE_ONE_OF); - public static final TranslatableComponent COMMAND_PLAYER_BAN_INFO_INFO = renderTranslationComponent(Keys.COMMAND_PLAYER_BAN_INFO_INFO); - public static final TranslatableComponent COMMAND_PLAYER_BAN_INFO_INFO_NOT_BANNED = renderTranslationComponent(Keys.COMMAND_PLAYER_BAN_INFO_INFO_NOT_BANNED); - public static final TranslatableComponent COMMAND_PLAYER_BAN_INFO_NOT_BANNED = renderTranslationComponent(Keys.COMMAND_PLAYER_BAN_INFO_NOT_BANNED); - public static final TranslatableComponent COMMAND_PLAYER_BAN_INFO_GET_REASON = renderTranslationComponent(Keys.COMMAND_PLAYER_BAN_INFO_GET_REASON); - public static final TranslatableComponent COMMAND_PLAYER_BAN_INFO_SET_REASON = renderTranslationComponent(Keys.COMMAND_PLAYER_BAN_INFO_SET_REASON); - public static final TranslatableComponent COMMAND_PLAYER_BAN_INFO_GET_TIME_TO = renderTranslationComponent(Keys.COMMAND_PLAYER_BAN_INFO_GET_TIME_TO); - public static final TranslatableComponent COMMAND_PLAYER_BAN_INFO_SET_TIME_TO = renderTranslationComponent(Keys.COMMAND_PLAYER_BAN_INFO_SET_TIME_TO); - public static final TranslatableComponent COMMAND_PLAYER_MUTE_INFO_INFO = renderTranslationComponent(Keys.COMMAND_PLAYER_MUTE_INFO_INFO); - public static final TranslatableComponent COMMAND_PLAYER_MUTE_INFO_INFO_NOT_MUTED = renderTranslationComponent(Keys.COMMAND_PLAYER_MUTE_INFO_INFO_NOT_MUTED); - public static final TranslatableComponent COMMAND_PLAYER_MUTE_INFO_NOT_MUTED = renderTranslationComponent(Keys.COMMAND_PLAYER_MUTE_INFO_NOT_MUTED); - public static final TranslatableComponent COMMAND_PLAYER_MUTE_INFO_GET_REASON = renderTranslationComponent(Keys.COMMAND_PLAYER_MUTE_INFO_GET_REASON); - public static final TranslatableComponent COMMAND_PLAYER_MUTE_INFO_SET_REASON = renderTranslationComponent(Keys.COMMAND_PLAYER_MUTE_INFO_SET_REASON); - public static final TranslatableComponent COMMAND_PLAYER_MUTE_INFO_GET_TIME_TO = renderTranslationComponent(Keys.COMMAND_PLAYER_MUTE_INFO_GET_TIME_TO); - public static final TranslatableComponent COMMAND_PLAYER_MUTE_INFO_SET_TIME_TO = renderTranslationComponent(Keys.COMMAND_PLAYER_MUTE_INFO_SET_TIME_TO); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_USE_ONE_OF = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_USE_ONE_OF); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE_FULL = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE_FULL); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_SET_GAME_MODE = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_SET_GAME_MODE); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_GAME_MODE_USE_ONE_OF = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_GAME_MODE_USE_ONE_OF); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH_FULL = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH_FULL); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_SET_HEALTH = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_SET_HEALTH); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_GET_AIR = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_AIR); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_GET_AIR_FULL = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_AIR_FULL); - public static final TranslatableComponent COMMAND_PLAYER_GAME_PARAMS_SET_AIR = renderTranslationComponent(Keys.COMMAND_PLAYER_GAME_PARAMS_SET_AIR); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_USE_ONE_OF = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_USE_ONE_OF); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_GET_RESOURCEPACK_TYPE = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_GET_RESOURCEPACK_TYPE); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_SET_RESOURCEPACK_TYPE = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_SET_RESOURCEPACK_TYPE); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_RESOURCEPACK_TYPE_USE_ONE_OF = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_RESOURCEPACK_TYPE_USE_ONE_OF); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_GET_SKIN = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_GET_SKIN); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_GET_NO_SKIN = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_GET_NO_SKIN); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_SET_SKIN = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_SET_SKIN); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_ADD_SKIN = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_ADD_SKIN); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_ADD_SKIN_ERROR = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_ADD_SKIN_ERROR); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_REMOVE_SKIN = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_REMOVE_SKIN); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_SKIN_NOT_FOUND = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_SKIN_NOT_FOUND); - public static final TranslatableComponent COMMAND_PLAYER_SETTINGS_SKIN_USE_ONE_OF = renderTranslationComponent(Keys.COMMAND_PLAYER_SETTINGS_SKIN_USE_ONE_OF); - public static final TranslatableComponent COMMAND_MSBLOCK_GIVE_WRONG_BLOCK = renderTranslationComponent(Keys.COMMAND_MSBLOCK_GIVE_WRONG_BLOCK); - public static final TranslatableComponent COMMAND_MSBLOCK_GIVE_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSBLOCK_GIVE_SUCCESS); - public static final TranslatableComponent COMMAND_MSBLOCK_RELOAD_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSBLOCK_RELOAD_SUCCESS); - public static final TranslatableComponent COMMAND_MSDECOR_GIVE_WRONG_DECOR = renderTranslationComponent(Keys.COMMAND_MSDECOR_GIVE_WRONG_DECOR); - public static final TranslatableComponent COMMAND_MSDECOR_GIVE_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSDECOR_GIVE_SUCCESS); - public static final TranslatableComponent COMMAND_MSDECOR_RELOAD_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSDECOR_RELOAD_SUCCESS); - public static final TranslatableComponent COMMAND_MSITEM_GIVE_WRONG_ITEM = renderTranslationComponent(Keys.COMMAND_MSITEM_GIVE_WRONG_ITEM); - public static final TranslatableComponent COMMAND_MSITEM_GIVE_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSITEM_GIVE_SUCCESS); - public static final TranslatableComponent COMMAND_MSITEM_RELOAD_SUCCESS = renderTranslationComponent(Keys.COMMAND_MSITEM_RELOAD_SUCCESS); - public static final TranslatableComponent COMMAND_DISCORD = renderTranslationComponent(Keys.COMMAND_DISCORD); - public static final TranslatableComponent COMMAND_DISCORD_LINK_SUCCESS = renderTranslationComponent(Keys.COMMAND_DISCORD_LINK_SUCCESS); - public static final TranslatableComponent COMMAND_DISCORD_UNLINK_NO_LINKS = renderTranslationComponent(Keys.COMMAND_DISCORD_UNLINK_NO_LINKS); - public static final TranslatableComponent COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS = renderTranslationComponent(Keys.COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS); - public static final TranslatableComponent COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS = renderTranslationComponent(Keys.COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS); - public static final TranslatableComponent COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND = renderTranslationComponent(Keys.COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND); - public static final TranslatableComponent COMMAND_SET_SERVER_SPAWN_TOO_BIG_COORDINATES = renderTranslationComponent(Keys.COMMAND_SET_SERVER_SPAWN_TOO_BIG_COORDINATES); - public static final TranslatableComponent COMMAND_SET_SERVER_SPAWN_SUCCESSFULLY_SET = renderTranslationComponent(Keys.COMMAND_SET_SERVER_SPAWN_SUCCESSFULLY_SET); - public static final TranslatableComponent DISCORD_SERVER_ENABLED = renderTranslationComponent(Keys.DISCORD_SERVER_ENABLED); - public static final TranslatableComponent DISCORD_SERVER_DISABLED = renderTranslationComponent(Keys.DISCORD_SERVER_DISABLED); - public static final TranslatableComponent DISCORD_BOT_STATUS = renderTranslationComponent(Keys.DISCORD_BOT_STATUS); - public static final TranslatableComponent DISCORD_NOT_A_USER = renderTranslationComponent(Keys.DISCORD_NOT_A_USER); - public static final TranslatableComponent DISCORD_NO_CODE = renderTranslationComponent(Keys.DISCORD_NO_CODE); - public static final TranslatableComponent DISCORD_INVALID_CODE = renderTranslationComponent(Keys.DISCORD_INVALID_CODE); - public static final TranslatableComponent DISCORD_CODE_ATTEMPTS_LIMIT_REACHED = renderTranslationComponent(Keys.DISCORD_CODE_ATTEMPTS_LIMIT_REACHED); - public static final TranslatableComponent DISCORD_MESSAGE_ATTEMPTS_LIMIT_REACHED = renderTranslationComponent(Keys.DISCORD_MESSAGE_ATTEMPTS_LIMIT_REACHED); - public static final TranslatableComponent DISCORD_UNKNOWN_COMMAND = renderTranslationComponent(Keys.DISCORD_UNKNOWN_COMMAND); - public static final TranslatableComponent DISCORD_NOT_LINKED = renderTranslationComponent(Keys.DISCORD_NOT_LINKED); - public static final TranslatableComponent DISCORD_ALREADY_LINKED = renderTranslationComponent(Keys.DISCORD_ALREADY_LINKED); - public static final TranslatableComponent DISCORD_SUCCESSFULLY_LINKED = renderTranslationComponent(Keys.DISCORD_SUCCESSFULLY_LINKED); - public static final TranslatableComponent DISCORD_BANNED = renderTranslationComponent(Keys.DISCORD_BANNED); - public static final TranslatableComponent DISCORD_UNBANNED = renderTranslationComponent(Keys.DISCORD_UNBANNED); - public static final TranslatableComponent DISCORD_MUTED = renderTranslationComponent(Keys.DISCORD_MUTED); - public static final TranslatableComponent DISCORD_UNMUTED = renderTranslationComponent(Keys.DISCORD_UNMUTED); - public static final TranslatableComponent DISCORD_EMBED_TITLE = renderTranslationComponent(Keys.DISCORD_EMBED_TITLE); - public static final TranslatableComponent DISCORD_SKIN_SERVICE_UNAVAILABLE = renderTranslationComponent(Keys.DISCORD_SKIN_SERVICE_UNAVAILABLE); - public static final TranslatableComponent DISCORD_SKIN_ONLY_ONE_IMG = renderTranslationComponent(Keys.DISCORD_SKIN_ONLY_ONE_IMG); - public static final TranslatableComponent DISCORD_SKIN_INVALID_IMG = renderTranslationComponent(Keys.DISCORD_SKIN_INVALID_IMG); - public static final TranslatableComponent DISCORD_SKIN_TOO_MANY_SKINS = renderTranslationComponent(Keys.DISCORD_SKIN_TOO_MANY_SKINS); - public static final TranslatableComponent DISCORD_SKIN_ALREADY_SET = renderTranslationComponent(Keys.DISCORD_SKIN_ALREADY_SET); - public static final TranslatableComponent DISCORD_SKIN_VARIANT_YES = renderTranslationComponent(Keys.DISCORD_SKIN_VARIANT_YES); - public static final TranslatableComponent DISCORD_SKIN_VARIANT_NO = renderTranslationComponent(Keys.DISCORD_SKIN_VARIANT_NO); - public static final TranslatableComponent DISCORD_SKIN_VARIANT_NO_REPLY = renderTranslationComponent(Keys.DISCORD_SKIN_VARIANT_NO_REPLY); - public static final TranslatableComponent DISCORD_SKIN_INVALID_NAME_REGEX = renderTranslationComponent(Keys.DISCORD_SKIN_INVALID_NAME_REGEX); - public static final TranslatableComponent DISCORD_SKIN_NO_NAME = renderTranslationComponent(Keys.DISCORD_SKIN_NO_NAME); - public static final TranslatableComponent DISCORD_SKIN_LIST_OF_SKINS = renderTranslationComponent(Keys.DISCORD_SKIN_LIST_OF_SKINS); - public static final TranslatableComponent DISCORD_SKIN_LIST_OF_SKIN_ACTIONS = renderTranslationComponent(Keys.DISCORD_SKIN_LIST_OF_SKIN_ACTIONS); - public static final TranslatableComponent DISCORD_SKIN_ACTION_EDIT_INFO = renderTranslationComponent(Keys.DISCORD_SKIN_ACTION_EDIT_INFO); - public static final TranslatableComponent DISCORD_SKIN_ACTION_RENAME_INFO = renderTranslationComponent(Keys.DISCORD_SKIN_ACTION_RENAME_INFO); - public static final TranslatableComponent DISCORD_SKIN_INVALID_INDEX = renderTranslationComponent(Keys.DISCORD_SKIN_INVALID_INDEX); - public static final TranslatableComponent DISCORD_SKIN_SUCCESSFULLY_ADDED = renderTranslationComponent(Keys.DISCORD_SKIN_SUCCESSFULLY_ADDED); - public static final TranslatableComponent DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT = renderTranslationComponent(Keys.DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT); - public static final TranslatableComponent DISCORD_SKIN_EDIT_ALREADY_SET = renderTranslationComponent(Keys.DISCORD_SKIN_EDIT_ALREADY_SET); - public static final TranslatableComponent DISCORD_SKIN_SUCCESSFULLY_EDITED = renderTranslationComponent(Keys.DISCORD_SKIN_SUCCESSFULLY_EDITED); - public static final TranslatableComponent DISCORD_SKIN_SUCCESSFULLY_EDITED_MINECRAFT = renderTranslationComponent(Keys.DISCORD_SKIN_SUCCESSFULLY_EDITED_MINECRAFT); - public static final TranslatableComponent DISCORD_SKIN_SUCCESSFULLY_REMOVED = renderTranslationComponent(Keys.DISCORD_SKIN_SUCCESSFULLY_REMOVED); - public static final TranslatableComponent DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT = renderTranslationComponent(Keys.DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT); - public static final TranslatableComponent DISCORD_SKIN_SUCCESSFULLY_RENAMED = renderTranslationComponent(Keys.DISCORD_SKIN_SUCCESSFULLY_RENAMED); - public static final TranslatableComponent DISCORD_SKIN_SUCCESSFULLY_RENAMED_MINECRAFT = renderTranslationComponent(Keys.DISCORD_SKIN_SUCCESSFULLY_RENAMED_MINECRAFT); - public static final TranslatableComponent DISCORD_COMMAND_LIST_OF_SKINS = renderTranslationComponent(Keys.DISCORD_COMMAND_LIST_OF_SKINS); - public static final TranslatableComponent DISCORD_COMMAND_SKIN_NOT_FOUND = renderTranslationComponent(Keys.DISCORD_COMMAND_SKIN_NOT_FOUND); - public static final TranslatableComponent DISCORD_COMMAND_INVALID_ARGUMENTS = renderTranslationComponent(Keys.DISCORD_COMMAND_INVALID_ARGUMENTS); - public static final TranslatableComponent MENU_SKINS_TITLE = renderTranslationComponent(Keys.MENU_SKINS_TITLE); - public static final TranslatableComponent MENU_SKINS_BUTTON_APPLY = renderTranslationComponent(Keys.MENU_SKINS_BUTTON_APPLY); - public static final TranslatableComponent MENU_SKINS_BUTTON_DELETE = renderTranslationComponent(Keys.MENU_SKINS_BUTTON_DELETE); - public static final TranslatableComponent MENU_SKINS_BUTTON_QUIT = renderTranslationComponent(Keys.MENU_SKINS_BUTTON_QUIT); - public static final TranslatableComponent MENU_DISCORD_TITLE = renderTranslationComponent(Keys.MENU_DISCORD_TITLE); - public static final TranslatableComponent MENU_DISCORD_NUMBERS_0 = renderTranslationComponent(Keys.MENU_DISCORD_NUMBERS_0); - public static final TranslatableComponent MENU_DISCORD_NUMBERS_1 = renderTranslationComponent(Keys.MENU_DISCORD_NUMBERS_1); - public static final TranslatableComponent MENU_DISCORD_NUMBERS_2 = renderTranslationComponent(Keys.MENU_DISCORD_NUMBERS_2); - public static final TranslatableComponent MENU_DISCORD_NUMBERS_3 = renderTranslationComponent(Keys.MENU_DISCORD_NUMBERS_3); - public static final TranslatableComponent MENU_DISCORD_NUMBERS_4 = renderTranslationComponent(Keys.MENU_DISCORD_NUMBERS_4); - public static final TranslatableComponent MENU_DISCORD_NUMBERS_5 = renderTranslationComponent(Keys.MENU_DISCORD_NUMBERS_5); - public static final TranslatableComponent MENU_DISCORD_NUMBERS_6 = renderTranslationComponent(Keys.MENU_DISCORD_NUMBERS_6); - public static final TranslatableComponent MENU_DISCORD_NUMBERS_7 = renderTranslationComponent(Keys.MENU_DISCORD_NUMBERS_7); - public static final TranslatableComponent MENU_DISCORD_NUMBERS_8 = renderTranslationComponent(Keys.MENU_DISCORD_NUMBERS_8); - public static final TranslatableComponent MENU_DISCORD_NUMBERS_9 = renderTranslationComponent(Keys.MENU_DISCORD_NUMBERS_9); - public static final TranslatableComponent MENU_CRAFTS_CATEGORIES_TITLE = renderTranslationComponent(Keys.MENU_CRAFTS_CATEGORIES_TITLE); - public static final TranslatableComponent MENU_CRAFTS_CATEGORY_TITLE = renderTranslationComponent(Keys.MENU_CRAFTS_CATEGORY_TITLE); - public static final TranslatableComponent MENU_CRAFTS_CRAFT_TITLE = renderTranslationComponent(Keys.MENU_CRAFTS_CRAFT_TITLE); - public static final TranslatableComponent MENU_CRAFTS_BUTTON_PREVIOUS_PAGE = renderTranslationComponent(Keys.MENU_CRAFTS_BUTTON_PREVIOUS_PAGE); - public static final TranslatableComponent MENU_CRAFTS_BUTTON_NEXT_PAGE = renderTranslationComponent(Keys.MENU_CRAFTS_BUTTON_NEXT_PAGE); - public static final TranslatableComponent MENU_PRONOUNS_TITLE = renderTranslationComponent(Keys.MENU_PRONOUNS_TITLE); - public static final TranslatableComponent MENU_PRONOUNS_BUTTON_HE_TITLE = renderTranslationComponent(Keys.MENU_PRONOUNS_BUTTON_HE_TITLE); - public static final TranslatableComponent MENU_PRONOUNS_BUTTON_HE_LORE = renderTranslationComponent(Keys.MENU_PRONOUNS_BUTTON_HE_LORE); - public static final TranslatableComponent MENU_PRONOUNS_BUTTON_SHE_TITLE = renderTranslationComponent(Keys.MENU_PRONOUNS_BUTTON_SHE_TITLE); - public static final TranslatableComponent MENU_PRONOUNS_BUTTON_SHE_LORE = renderTranslationComponent(Keys.MENU_PRONOUNS_BUTTON_SHE_LORE); - public static final TranslatableComponent MENU_PRONOUNS_BUTTON_THEY_TITLE = renderTranslationComponent(Keys.MENU_PRONOUNS_BUTTON_THEY_TITLE); - public static final TranslatableComponent MENU_PRONOUNS_BUTTON_THEY_LORE = renderTranslationComponent(Keys.MENU_PRONOUNS_BUTTON_THEY_LORE); - public static final TranslatableComponent MENU_RESOURCE_PACK_TITLE = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_TITLE); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_INFO_TITLE = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_TITLE); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_INFO_LORE_0 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_LORE_0); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_INFO_LORE_1 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_LORE_1); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_INFO_LORE_2 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_LORE_2); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_INFO_LORE_3 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_LORE_3); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_INFO_LORE_4 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_LORE_4); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_NONE_TITLE = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_NONE_TITLE); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_NONE_LORE_0 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_NONE_LORE_0); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_NONE_LORE_1 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_NONE_LORE_1); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_NONE_KICK_TITLE = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_NONE_KICK_TITLE); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_NONE_KICK_SUBTITLE = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_NONE_KICK_SUBTITLE); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_LITE_TITLE = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_LITE_TITLE); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_LITE_LORE_0 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_LITE_LORE_0); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_LITE_LORE_1 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_LITE_LORE_1); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_LITE_LORE_2 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_LITE_LORE_2); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_LITE_LORE_3 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_LITE_LORE_3); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_TITLE = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_TITLE); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_0 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_0); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_1 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_1); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_2 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_2); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_3 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_3); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_4 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_4); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_5 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_5); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_6 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_6); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_7 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_7); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_8 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_8); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_9 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_9); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_10 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_10); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_11 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_11); - public static final TranslatableComponent MENU_RESOURCE_PACK_BUTTON_FULL_LORE_12 = renderTranslationComponent(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_12); - public static final TranslatableComponent MENU_RENAMES_TITLE = renderTranslationComponent(Keys.MENU_RENAMES_TITLE); - public static final TranslatableComponent MENU_RENAMES_BUTTON_PREVIOUS_PAGE = renderTranslationComponent(Keys.MENU_RENAMES_BUTTON_PREVIOUS_PAGE); - public static final TranslatableComponent MENU_RENAMES_BUTTON_NEXT_PAGE = renderTranslationComponent(Keys.MENU_RENAMES_BUTTON_NEXT_PAGE); - public static final TranslatableComponent MENU_RENAME_TITLE = renderTranslationComponent(Keys.MENU_RENAME_TITLE); - public static final TranslatableComponent MENU_RENAME_NO_EXP = renderTranslationComponent(Keys.MENU_RENAME_NO_EXP); - public static final TranslatableComponent REGISTRATION_ANONYMOUS_NAME = renderTranslationComponent(Keys.REGISTRATION_ANONYMOUS_NAME); - public static final TranslatableComponent REGISTRATION_ONLY_CYRILLIC = renderTranslationComponent(Keys.REGISTRATION_ONLY_CYRILLIC); - public static final TranslatableComponent REGISTRATION_SIGN_FIRST_NAME_0 = renderTranslationComponent(Keys.REGISTRATION_SIGN_FIRST_NAME_0); - public static final TranslatableComponent REGISTRATION_SIGN_FIRST_NAME_1 = renderTranslationComponent(Keys.REGISTRATION_SIGN_FIRST_NAME_1); - public static final TranslatableComponent REGISTRATION_SIGN_FIRST_NAME_2 = renderTranslationComponent(Keys.REGISTRATION_SIGN_FIRST_NAME_2); - public static final TranslatableComponent REGISTRATION_SIGN_FIRST_NAME_3 = renderTranslationComponent(Keys.REGISTRATION_SIGN_FIRST_NAME_3); - public static final TranslatableComponent REGISTRATION_SIGN_LAST_NAME_0 = renderTranslationComponent(Keys.REGISTRATION_SIGN_LAST_NAME_0); - public static final TranslatableComponent REGISTRATION_SIGN_LAST_NAME_1 = renderTranslationComponent(Keys.REGISTRATION_SIGN_LAST_NAME_1); - public static final TranslatableComponent REGISTRATION_SIGN_LAST_NAME_2 = renderTranslationComponent(Keys.REGISTRATION_SIGN_LAST_NAME_2); - public static final TranslatableComponent REGISTRATION_SIGN_LAST_NAME_3 = renderTranslationComponent(Keys.REGISTRATION_SIGN_LAST_NAME_3); - public static final TranslatableComponent REGISTRATION_SIGN_PATRONYMIC_0 = renderTranslationComponent(Keys.REGISTRATION_SIGN_PATRONYMIC_0); - public static final TranslatableComponent REGISTRATION_SIGN_PATRONYMIC_1 = renderTranslationComponent(Keys.REGISTRATION_SIGN_PATRONYMIC_1); - public static final TranslatableComponent REGISTRATION_SIGN_PATRONYMIC_2 = renderTranslationComponent(Keys.REGISTRATION_SIGN_PATRONYMIC_2); - public static final TranslatableComponent REGISTRATION_SIGN_PATRONYMIC_3 = renderTranslationComponent(Keys.REGISTRATION_SIGN_PATRONYMIC_3); - public static final TranslatableComponent REGISTRATION_MESSAGE_0 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_0); - public static final TranslatableComponent REGISTRATION_MESSAGE_1 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_1); - public static final TranslatableComponent REGISTRATION_MESSAGE_2 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_2); - public static final TranslatableComponent REGISTRATION_MESSAGE_3 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_3); - public static final TranslatableComponent REGISTRATION_MESSAGE_4 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_4); - public static final TranslatableComponent REGISTRATION_MESSAGE_5 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_5); - public static final TranslatableComponent REGISTRATION_MESSAGE_6 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_6); - public static final TranslatableComponent REGISTRATION_MESSAGE_7 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_7); - public static final TranslatableComponent REGISTRATION_MESSAGE_8 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_8); - public static final TranslatableComponent REGISTRATION_MESSAGE_9 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_9); - public static final TranslatableComponent REGISTRATION_MESSAGE_10 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_10); - public static final TranslatableComponent REGISTRATION_MESSAGE_11 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_11); - public static final TranslatableComponent REGISTRATION_MESSAGE_12 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_12); - public static final TranslatableComponent REGISTRATION_MESSAGE_13 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_13); - public static final TranslatableComponent REGISTRATION_MESSAGE_14 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_14); - public static final TranslatableComponent REGISTRATION_MESSAGE_15 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_15); - public static final TranslatableComponent REGISTRATION_MESSAGE_16 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_16); - public static final TranslatableComponent REGISTRATION_MESSAGE_17 = renderTranslationComponent(Keys.REGISTRATION_MESSAGE_17); - public static final TranslatableComponent CHAT_HOVER_NAME = renderTranslationComponent(Keys.CHAT_HOVER_NAME); - public static final TranslatableComponent CHAT_HOVER_MESSAGE = renderTranslationComponent(Keys.CHAT_HOVER_MESSAGE); - public static final TranslatableComponent CHAT_LOCAL_FORMAT = renderTranslationComponent(Keys.CHAT_LOCAL_FORMAT); - public static final TranslatableComponent CHAT_GLOBAL_FORMAT = renderTranslationComponent(Keys.CHAT_GLOBAL_FORMAT); - public static final TranslatableComponent CHAT_PRIVATE_FORMAT_GLOBAL = renderTranslationComponent(Keys.CHAT_PRIVATE_FORMAT_GLOBAL); - public static final TranslatableComponent CHAT_PRIVATE_FORMAT_SENDER = renderTranslationComponent(Keys.CHAT_PRIVATE_FORMAT_SENDER); - public static final TranslatableComponent CHAT_PRIVATE_FORMAT_RECEIVER = renderTranslationComponent(Keys.CHAT_PRIVATE_FORMAT_RECEIVER); - public static final TranslatableComponent CHAT_DISCORD_FORMAT = renderTranslationComponent(Keys.CHAT_DISCORD_FORMAT); - public static final TranslatableComponent CHAT_DISCORD_FORMAT_REPLYING = renderTranslationComponent(Keys.CHAT_DISCORD_FORMAT_REPLYING); - public static final TranslatableComponent CHAT_DISCORD_FORMAT_GLOBAL_TO_LOCAL = renderTranslationComponent(Keys.CHAT_DISCORD_FORMAT_GLOBAL_TO_LOCAL); - public static final TranslatableComponent CHAT_DISCORD_FORMAT_GLOBAL_TO_GLOBAL = renderTranslationComponent(Keys.CHAT_DISCORD_FORMAT_GLOBAL_TO_GLOBAL); - public static final TranslatableComponent CHAT_DISCORD_ATTACHMENT = renderTranslationComponent(Keys.CHAT_DISCORD_ATTACHMENT); - public static final TranslatableComponent CHAT_DISCORD_ATTACHMENTS = renderTranslationComponent(Keys.CHAT_DISCORD_ATTACHMENTS); - public static final TranslatableComponent CHAT_ME_FORMAT = renderTranslationComponent(Keys.CHAT_ME_FORMAT); - public static final TranslatableComponent CHAT_DO_FORMAT = renderTranslationComponent(Keys.CHAT_DO_FORMAT); - public static final TranslatableComponent CHAT_IT_FORMAT = renderTranslationComponent(Keys.CHAT_IT_FORMAT); - public static final TranslatableComponent CHAT_TO_DO_FORMAT = renderTranslationComponent(Keys.CHAT_TO_DO_FORMAT); - public static final TranslatableComponent CHAT_TRY_FORMAT = renderTranslationComponent(Keys.CHAT_TRY_FORMAT); - public static final TranslatableComponent CHAT_DEATH_FORMAT_UNO = renderTranslationComponent(Keys.CHAT_DEATH_FORMAT_UNO); - public static final TranslatableComponent CHAT_DEATH_FORMAT_DUO = renderTranslationComponent(Keys.CHAT_DEATH_FORMAT_DUO); - public static final TranslatableComponent CHAT_JOIN_FORMAT = renderTranslationComponent(Keys.CHAT_JOIN_FORMAT); - public static final TranslatableComponent CHAT_QUIT_FORMAT = renderTranslationComponent(Keys.CHAT_QUIT_FORMAT); - public static final TranslatableComponent PLAYER_NAME_NICKNAME = renderTranslationComponent(Keys.PLAYER_NAME_NICKNAME); - public static final TranslatableComponent PLAYER_NAME_FIRST_NAME = renderTranslationComponent(Keys.PLAYER_NAME_FIRST_NAME); - public static final TranslatableComponent PLAYER_NAME_LAST_NAME = renderTranslationComponent(Keys.PLAYER_NAME_LAST_NAME); - public static final TranslatableComponent PLAYER_NAME_PATRONYMIC = renderTranslationComponent(Keys.PLAYER_NAME_PATRONYMIC); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_JOIN = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_JOIN); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_QUIT = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_QUIT); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_SPIT = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_SPIT); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_FART = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_FART); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_PRONOUNS = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_PRONOUNS); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_TRAVELER = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_TRAVELER); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_SIT = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_SIT); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_GET_UP = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_GET_UP); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_DEATH = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_DEATH); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_KILL = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_KILL); - public static final TranslatableComponent PLAYER_PRONOUNS_HE_SAID = renderTranslationComponent(Keys.PLAYER_PRONOUNS_HE_SAID); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_JOIN = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_JOIN); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_QUIT = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_QUIT); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_SPIT = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_SPIT); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_FART = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_FART); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_PRONOUNS = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_PRONOUNS); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_TRAVELER = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_TRAVELER); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_SIT = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_SIT); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_GET_UP = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_GET_UP); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_DEATH = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_DEATH); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_KILL = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_KILL); - public static final TranslatableComponent PLAYER_PRONOUNS_SHE_SAID = renderTranslationComponent(Keys.PLAYER_PRONOUNS_SHE_SAID); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_JOIN = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_JOIN); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_QUIT = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_QUIT); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_SPIT = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_SPIT); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_FART = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_FART); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_PRONOUNS = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_PRONOUNS); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_TRAVELER = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_TRAVELER); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_SIT = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_SIT); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_GET_UP = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_GET_UP); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_DEATH = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_DEATH); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_KILL = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_KILL); - public static final TranslatableComponent PLAYER_PRONOUNS_THEY_SAID = renderTranslationComponent(Keys.PLAYER_PRONOUNS_THEY_SAID); - // - - @Contract(" -> fail") - private Components() throws AssertionError { - throw new AssertionError("Utility class"); - } - } - - /** - * This class provides strings for various messages. Each string is a - * translation of the corresponding key. All keys are obtained from the - * {@link Keys} class. - * - * @see Components - * @see LanguageFile#renderTranslation(String) - */ - public static final class Strings { - // - public static final String FORMAT_LEAVE_MESSAGE = renderTranslation(Keys.FORMAT_LEAVE_MESSAGE); - public static final String LINK_HOVER = renderTranslation(Keys.LINK_HOVER); - public static final String COMMAND_HOVER_SUGGEST = renderTranslation(Keys.COMMAND_HOVER_SUGGEST); - public static final String COMMAND_HOVER_RUN = renderTranslation(Keys.COMMAND_HOVER_RUN); - public static final String ON_DISABLE_MESSAGE_TITLE = renderTranslation(Keys.ON_DISABLE_MESSAGE_TITLE); - public static final String ON_DISABLE_MESSAGE_SUBTITLE = renderTranslation(Keys.ON_DISABLE_MESSAGE_SUBTITLE); - public static final String SERVER_NOT_FULLY_LOADED_TITLE = renderTranslation(Keys.SERVER_NOT_FULLY_LOADED_TITLE); - public static final String SERVER_NOT_FULLY_LOADED_SUBTITLE = renderTranslation(Keys.SERVER_NOT_FULLY_LOADED_SUBTITLE); - public static final String SOMETHING_WENT_WRONG_TITLE = renderTranslation(Keys.SOMETHING_WENT_WRONG_TITLE); - public static final String SOMETHING_WENT_WRONG_SUBTITLE = renderTranslation(Keys.SOMETHING_WENT_WRONG_SUBTITLE); - public static final String INFO_PLAYER_FILE_CREATED = renderTranslation(Keys.INFO_PLAYER_FILE_CREATED); - public static final String INFO_PLAYER_ITEM_REMOVED = renderTranslation(Keys.INFO_PLAYER_ITEM_REMOVED); - public static final String INFO_PLAYER_ADDED_IP = renderTranslation(Keys.INFO_PLAYER_ADDED_IP); - public static final String INFO_PLAYER_DEATH_INFO = renderTranslation(Keys.INFO_PLAYER_DEATH_INFO); - public static final String WARNING_YOU_CANT_DO_THIS_NOW = renderTranslation(Keys.WARNING_YOU_CANT_DO_THIS_NOW); - public static final String ERROR_PLAYER_NOT_ONLINE = renderTranslation(Keys.ERROR_PLAYER_NOT_ONLINE); - public static final String ERROR_ID_NOT_FOUND = renderTranslation(Keys.ERROR_ID_NOT_FOUND); - public static final String ERROR_PLAYER_NOT_FOUND = renderTranslation(Keys.ERROR_PLAYER_NOT_FOUND); - public static final String ERROR_SOMETHING_WENT_WRONG = renderTranslation(Keys.ERROR_SOMETHING_WENT_WRONG); - public static final String ERROR_WRONG_FORMAT = renderTranslation(Keys.ERROR_WRONG_FORMAT); - public static final String ERROR_ONLY_PLAYER_COMMAND = renderTranslation(Keys.ERROR_ONLY_PLAYER_COMMAND); - public static final String ERROR_UNKNOWN_COMMAND = renderTranslation(Keys.ERROR_UNKNOWN_COMMAND); - public static final String ERROR_NO_PERMISSION = renderTranslation(Keys.ERROR_NO_PERMISSION); - public static final String ERROR_FLYING_PLAYER = renderTranslation(Keys.ERROR_FLYING_PLAYER); - public static final String ERROR_FLYING_VEHICLE = renderTranslation(Keys.ERROR_FLYING_VEHICLE); - public static final String ERROR_CONNECTION_THROTTLE = renderTranslation(Keys.ERROR_CONNECTION_THROTTLE); - public static final String ERROR_TOO_MANY_PACKETS = renderTranslation(Keys.ERROR_TOO_MANY_PACKETS); - public static final String RESOURCE_PACK_ACCEPTED = renderTranslation(Keys.RESOURCE_PACK_ACCEPTED); - public static final String RESOURCE_PACK_DECLINED_CONSOLE = renderTranslation(Keys.RESOURCE_PACK_DECLINED_CONSOLE); - public static final String RESOURCE_PACK_DECLINED_RECEIVER_TITLE = renderTranslation(Keys.RESOURCE_PACK_DECLINED_RECEIVER_TITLE); - public static final String RESOURCE_PACK_DECLINED_RECEIVER_SUBTITLE = renderTranslation(Keys.RESOURCE_PACK_DECLINED_RECEIVER_SUBTITLE); - public static final String RESOURCE_PACK_SUCCESSFULLY_LOADED = renderTranslation(Keys.RESOURCE_PACK_SUCCESSFULLY_LOADED); - public static final String RESOURCE_PACK_FAILED_DOWNLOAD_CONSOLE = renderTranslation(Keys.RESOURCE_PACK_FAILED_DOWNLOAD_CONSOLE); - public static final String RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_TITLE = renderTranslation(Keys.RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_TITLE); - public static final String RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_SUBTITLE = renderTranslation(Keys.RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_SUBTITLE); - public static final String BOOK_ANONYMOUS = renderTranslation(Keys.BOOK_ANONYMOUS); - public static final String PRE_LOGIN_BANNED_TITLE = renderTranslation(Keys.PRE_LOGIN_BANNED_TITLE); - public static final String PRE_LOGIN_BANNED_SUBTITLE = renderTranslation(Keys.PRE_LOGIN_BANNED_SUBTITLE); - public static final String PRE_LOGIN_WHITELISTED_TITLE = renderTranslation(Keys.PRE_LOGIN_WHITELISTED_TITLE); - public static final String PRE_LOGIN_WHITELISTED_SUBTITLE = renderTranslation(Keys.PRE_LOGIN_WHITELISTED_SUBTITLE); - public static final String PRE_LOGIN_TECH_WORKS_TITLE = renderTranslation(Keys.PRE_LOGIN_TECH_WORKS_TITLE); - public static final String PRE_LOGIN_TECH_WORKS_SUBTITLE = renderTranslation(Keys.PRE_LOGIN_TECH_WORKS_SUBTITLE); - public static final String COMMAND_BAN_DEFAULT_REASON = renderTranslation(Keys.COMMAND_BAN_DEFAULT_REASON); - public static final String COMMAND_BAN_ALREADY_SENDER = renderTranslation(Keys.COMMAND_BAN_ALREADY_SENDER); - public static final String COMMAND_BAN_MESSAGE_RECEIVER_TITLE = renderTranslation(Keys.COMMAND_BAN_MESSAGE_RECEIVER_TITLE); - public static final String COMMAND_BAN_MESSAGE_RECEIVER_SUBTITLE = renderTranslation(Keys.COMMAND_BAN_MESSAGE_RECEIVER_SUBTITLE); - public static final String COMMAND_BAN_MESSAGE_SENDER = renderTranslation(Keys.COMMAND_BAN_MESSAGE_SENDER); - public static final String COMMAND_BAN_TIME_FOREVER = renderTranslation(Keys.COMMAND_BAN_TIME_FOREVER); - public static final String COMMAND_UNBAN_NOT_BANNED = renderTranslation(Keys.COMMAND_UNBAN_NOT_BANNED); - public static final String COMMAND_UNBAN_MESSAGE_SENDER = renderTranslation(Keys.COMMAND_UNBAN_MESSAGE_SENDER); - public static final String COMMAND_MUTE_DEFAULT_REASON = renderTranslation(Keys.COMMAND_MUTE_DEFAULT_REASON); - public static final String COMMAND_MUTE_ALREADY_RECEIVER = renderTranslation(Keys.COMMAND_MUTE_ALREADY_RECEIVER); - public static final String COMMAND_MUTE_ALREADY_SENDER = renderTranslation(Keys.COMMAND_MUTE_ALREADY_SENDER); - public static final String COMMAND_MUTE_MESSAGE_RECEIVER = renderTranslation(Keys.COMMAND_MUTE_MESSAGE_RECEIVER); - public static final String COMMAND_MUTE_MESSAGE_SENDER = renderTranslation(Keys.COMMAND_MUTE_MESSAGE_SENDER); - public static final String COMMAND_UNMUTE_NOT_MUTED = renderTranslation(Keys.COMMAND_UNMUTE_NOT_MUTED); - public static final String COMMAND_UNMUTE_SENDER_MESSAGE = renderTranslation(Keys.COMMAND_UNMUTE_SENDER_MESSAGE); - public static final String COMMAND_UNMUTE_RECEIVER_MESSAGE = renderTranslation(Keys.COMMAND_UNMUTE_RECEIVER_MESSAGE); - public static final String COMMAND_KICK_DEFAULT_REASON = renderTranslation(Keys.COMMAND_KICK_DEFAULT_REASON); - public static final String COMMAND_KICK_MESSAGE_RECEIVER_TITLE = renderTranslation(Keys.COMMAND_KICK_MESSAGE_RECEIVER_TITLE); - public static final String COMMAND_KICK_MESSAGE_RECEIVER_SUBTITLE = renderTranslation(Keys.COMMAND_KICK_MESSAGE_RECEIVER_SUBTITLE); - public static final String COMMAND_KICK_MESSAGE_SENDER = renderTranslation(Keys.COMMAND_KICK_MESSAGE_SENDER); - public static final String COMMAND_WHITE_LIST_RELOAD = renderTranslation(Keys.COMMAND_WHITE_LIST_RELOAD); - public static final String COMMAND_WHITE_LIST_ADD_NICKNAME_WARNING = renderTranslation(Keys.COMMAND_WHITE_LIST_ADD_NICKNAME_WARNING); - public static final String COMMAND_WHITE_LIST_ADD_ALREADY = renderTranslation(Keys.COMMAND_WHITE_LIST_ADD_ALREADY); - public static final String COMMAND_WHITE_LIST_ADD_SENDER_MESSAGE = renderTranslation(Keys.COMMAND_WHITE_LIST_ADD_SENDER_MESSAGE); - public static final String COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_TITLE = renderTranslation(Keys.COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_TITLE); - public static final String COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_SUBTITLE = renderTranslation(Keys.COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_SUBTITLE); - public static final String COMMAND_WHITE_LIST_REMOVE_SENDER_MESSAGE = renderTranslation(Keys.COMMAND_WHITE_LIST_REMOVE_SENDER_MESSAGE); - public static final String COMMAND_WHITE_LIST_REMOVE_NOT_FOUND = renderTranslation(Keys.COMMAND_WHITE_LIST_REMOVE_NOT_FOUND); - public static final String COMMAND_SIT_IN_AIR = renderTranslation(Keys.COMMAND_SIT_IN_AIR); - public static final String COMMAND_TRY_VARIANT_SUCCESS = renderTranslation(Keys.COMMAND_TRY_VARIANT_SUCCESS); - public static final String COMMAND_TRY_VARIANT_FAIL = renderTranslation(Keys.COMMAND_TRY_VARIANT_FAIL); - public static final String COMMAND_TELEPORT_TO_LAST_DEATH_NO_POSITION = renderTranslation(Keys.COMMAND_TELEPORT_TO_LAST_DEATH_NO_POSITION); - public static final String COMMAND_TELEPORT_TO_LAST_DEATH_SENDER_MESSAGE = renderTranslation(Keys.COMMAND_TELEPORT_TO_LAST_DEATH_SENDER_MESSAGE); - public static final String COMMAND_WORLD_TELEPORT_WORLD_NOT_FOUND = renderTranslation(Keys.COMMAND_WORLD_TELEPORT_WORLD_NOT_FOUND); - public static final String COMMAND_WORLD_TELEPORT_TOO_BIG_COORDINATES = renderTranslation(Keys.COMMAND_WORLD_TELEPORT_TOO_BIG_COORDINATES); - public static final String COMMAND_WORLD_TELEPORT_SENDER_MESSAGE = renderTranslation(Keys.COMMAND_WORLD_TELEPORT_SENDER_MESSAGE); - public static final String COMMAND_GET_MAP_LOCATION_NO_MAP_IN_RIGHT_HAND = renderTranslation(Keys.COMMAND_GET_MAP_LOCATION_NO_MAP_IN_RIGHT_HAND); - public static final String COMMAND_GET_MAP_LOCATION_FORMAT = renderTranslation(Keys.COMMAND_GET_MAP_LOCATION_FORMAT); - public static final String COMMAND_GET_MAP_LOCATION_COMMAND_BUTTON_TEXT = renderTranslation(Keys.COMMAND_GET_MAP_LOCATION_COMMAND_BUTTON_TEXT); - public static final String COMMAND_MSESSENTIALS_RELOAD_SUCCESS = renderTranslation(Keys.COMMAND_MSESSENTIALS_RELOAD_SUCCESS); - public static final String COMMAND_MSESSENTIALS_UPDATE_IDS_SUCCESS = renderTranslation(Keys.COMMAND_MSESSENTIALS_UPDATE_IDS_SUCCESS); - public static final String COMMAND_MSESSENTIALS_UPDATE_MUTES_SUCCESS = renderTranslation(Keys.COMMAND_MSESSENTIALS_UPDATE_MUTES_SUCCESS); - public static final String COMMAND_MSCORE_RELOAD_LANGUAGE_SUCCESS = renderTranslation(Keys.COMMAND_MSCORE_RELOAD_LANGUAGE_SUCCESS); - public static final String COMMAND_MSCORE_RELOAD_CONFIG_SUCCESS = renderTranslation(Keys.COMMAND_MSCORE_RELOAD_CONFIG_SUCCESS); - public static final String COMMAND_PLAYER_UPDATE_SUCCESS = renderTranslation(Keys.COMMAND_PLAYER_UPDATE_SUCCESS); - public static final String COMMAND_PLAYER_FIRST_JOIN = renderTranslation(Keys.COMMAND_PLAYER_FIRST_JOIN); - public static final String COMMAND_PLAYER_NAME_ABOUT = renderTranslation(Keys.COMMAND_PLAYER_NAME_ABOUT); - public static final String COMMAND_PLAYER_NAME_FULL_RESET_SENDER = renderTranslation(Keys.COMMAND_PLAYER_NAME_FULL_RESET_SENDER); - public static final String COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_TITLE = renderTranslation(Keys.COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_TITLE); - public static final String COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_SUBTITLE = renderTranslation(Keys.COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_SUBTITLE); - public static final String COMMAND_PLAYER_NAME_GET_FIRST_NAME = renderTranslation(Keys.COMMAND_PLAYER_NAME_GET_FIRST_NAME); - public static final String COMMAND_PLAYER_NAME_GET_LAST_NAME = renderTranslation(Keys.COMMAND_PLAYER_NAME_GET_LAST_NAME); - public static final String COMMAND_PLAYER_NAME_GET_PATRONYMIC = renderTranslation(Keys.COMMAND_PLAYER_NAME_GET_PATRONYMIC); - public static final String COMMAND_PLAYER_NAME_NOW_FULL = renderTranslation(Keys.COMMAND_PLAYER_NAME_NOW_FULL); - public static final String COMMAND_PLAYER_PRONOUNS_GET = renderTranslation(Keys.COMMAND_PLAYER_PRONOUNS_GET); - public static final String COMMAND_PLAYER_PRONOUNS_SET = renderTranslation(Keys.COMMAND_PLAYER_PRONOUNS_SET); - public static final String COMMAND_PLAYER_PRONOUNS_USE_ONE_OF = renderTranslation(Keys.COMMAND_PLAYER_PRONOUNS_USE_ONE_OF); - public static final String COMMAND_PLAYER_BAN_INFO_INFO = renderTranslation(Keys.COMMAND_PLAYER_BAN_INFO_INFO); - public static final String COMMAND_PLAYER_BAN_INFO_INFO_NOT_BANNED = renderTranslation(Keys.COMMAND_PLAYER_BAN_INFO_INFO_NOT_BANNED); - public static final String COMMAND_PLAYER_BAN_INFO_NOT_BANNED = renderTranslation(Keys.COMMAND_PLAYER_BAN_INFO_NOT_BANNED); - public static final String COMMAND_PLAYER_BAN_INFO_GET_REASON = renderTranslation(Keys.COMMAND_PLAYER_BAN_INFO_GET_REASON); - public static final String COMMAND_PLAYER_BAN_INFO_SET_REASON = renderTranslation(Keys.COMMAND_PLAYER_BAN_INFO_SET_REASON); - public static final String COMMAND_PLAYER_BAN_INFO_GET_TIME_TO = renderTranslation(Keys.COMMAND_PLAYER_BAN_INFO_GET_TIME_TO); - public static final String COMMAND_PLAYER_BAN_INFO_SET_TIME_TO = renderTranslation(Keys.COMMAND_PLAYER_BAN_INFO_SET_TIME_TO); - public static final String COMMAND_PLAYER_MUTE_INFO_INFO = renderTranslation(Keys.COMMAND_PLAYER_MUTE_INFO_INFO); - public static final String COMMAND_PLAYER_MUTE_INFO_INFO_NOT_MUTED = renderTranslation(Keys.COMMAND_PLAYER_MUTE_INFO_INFO_NOT_MUTED); - public static final String COMMAND_PLAYER_MUTE_INFO_NOT_MUTED = renderTranslation(Keys.COMMAND_PLAYER_MUTE_INFO_NOT_MUTED); - public static final String COMMAND_PLAYER_MUTE_INFO_GET_REASON = renderTranslation(Keys.COMMAND_PLAYER_MUTE_INFO_GET_REASON); - public static final String COMMAND_PLAYER_MUTE_INFO_SET_REASON = renderTranslation(Keys.COMMAND_PLAYER_MUTE_INFO_SET_REASON); - public static final String COMMAND_PLAYER_MUTE_INFO_GET_TIME_TO = renderTranslation(Keys.COMMAND_PLAYER_MUTE_INFO_GET_TIME_TO); - public static final String COMMAND_PLAYER_MUTE_INFO_SET_TIME_TO = renderTranslation(Keys.COMMAND_PLAYER_MUTE_INFO_SET_TIME_TO); - public static final String COMMAND_PLAYER_GAME_PARAMS_USE_ONE_OF = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_USE_ONE_OF); - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE); - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE_FULL = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE_FULL); - public static final String COMMAND_PLAYER_GAME_PARAMS_SET_GAME_MODE = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_SET_GAME_MODE); - public static final String COMMAND_PLAYER_GAME_PARAMS_GAME_MODE_USE_ONE_OF = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_GAME_MODE_USE_ONE_OF); - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH); - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH_FULL = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH_FULL); - public static final String COMMAND_PLAYER_GAME_PARAMS_SET_HEALTH = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_SET_HEALTH); - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_AIR = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_AIR); - public static final String COMMAND_PLAYER_GAME_PARAMS_GET_AIR_FULL = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_GET_AIR_FULL); - public static final String COMMAND_PLAYER_GAME_PARAMS_SET_AIR = renderTranslation(Keys.COMMAND_PLAYER_GAME_PARAMS_SET_AIR); - public static final String COMMAND_PLAYER_SETTINGS_USE_ONE_OF = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_USE_ONE_OF); - public static final String COMMAND_PLAYER_SETTINGS_GET_RESOURCEPACK_TYPE = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_GET_RESOURCEPACK_TYPE); - public static final String COMMAND_PLAYER_SETTINGS_SET_RESOURCEPACK_TYPE = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_SET_RESOURCEPACK_TYPE); - public static final String COMMAND_PLAYER_SETTINGS_RESOURCEPACK_TYPE_USE_ONE_OF = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_RESOURCEPACK_TYPE_USE_ONE_OF); - public static final String COMMAND_PLAYER_SETTINGS_GET_SKIN = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_GET_SKIN); - public static final String COMMAND_PLAYER_SETTINGS_GET_NO_SKIN = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_GET_NO_SKIN); - public static final String COMMAND_PLAYER_SETTINGS_SET_SKIN = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_SET_SKIN); - public static final String COMMAND_PLAYER_SETTINGS_ADD_SKIN = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_ADD_SKIN); - public static final String COMMAND_PLAYER_SETTINGS_ADD_SKIN_ERROR = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_ADD_SKIN_ERROR); - public static final String COMMAND_PLAYER_SETTINGS_REMOVE_SKIN = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_REMOVE_SKIN); - public static final String COMMAND_PLAYER_SETTINGS_SKIN_NOT_FOUND = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_SKIN_NOT_FOUND); - public static final String COMMAND_PLAYER_SETTINGS_SKIN_USE_ONE_OF = renderTranslation(Keys.COMMAND_PLAYER_SETTINGS_SKIN_USE_ONE_OF); - public static final String COMMAND_MSBLOCK_GIVE_WRONG_BLOCK = renderTranslation(Keys.COMMAND_MSBLOCK_GIVE_WRONG_BLOCK); - public static final String COMMAND_MSBLOCK_GIVE_SUCCESS = renderTranslation(Keys.COMMAND_MSBLOCK_GIVE_SUCCESS); - public static final String COMMAND_MSBLOCK_RELOAD_SUCCESS = renderTranslation(Keys.COMMAND_MSBLOCK_RELOAD_SUCCESS); - public static final String COMMAND_MSDECOR_GIVE_WRONG_DECOR = renderTranslation(Keys.COMMAND_MSDECOR_GIVE_WRONG_DECOR); - public static final String COMMAND_MSDECOR_GIVE_SUCCESS = renderTranslation(Keys.COMMAND_MSDECOR_GIVE_SUCCESS); - public static final String COMMAND_MSDECOR_RELOAD_SUCCESS = renderTranslation(Keys.COMMAND_MSDECOR_RELOAD_SUCCESS); - public static final String COMMAND_MSITEM_GIVE_WRONG_ITEM = renderTranslation(Keys.COMMAND_MSITEM_GIVE_WRONG_ITEM); - public static final String COMMAND_MSITEM_GIVE_SUCCESS = renderTranslation(Keys.COMMAND_MSITEM_GIVE_SUCCESS); - public static final String COMMAND_MSITEM_RELOAD_SUCCESS = renderTranslation(Keys.COMMAND_MSITEM_RELOAD_SUCCESS); - public static final String COMMAND_DISCORD = renderTranslation(Keys.COMMAND_DISCORD); - public static final String COMMAND_DISCORD_LINK_SUCCESS = renderTranslation(Keys.COMMAND_DISCORD_LINK_SUCCESS); - public static final String COMMAND_DISCORD_UNLINK_NO_LINKS = renderTranslation(Keys.COMMAND_DISCORD_UNLINK_NO_LINKS); - public static final String COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS = renderTranslation(Keys.COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS); - public static final String COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS = renderTranslation(Keys.COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS); - public static final String COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND = renderTranslation(Keys.COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND); - public static final String COMMAND_SET_SERVER_SPAWN_TOO_BIG_COORDINATES = renderTranslation(Keys.COMMAND_SET_SERVER_SPAWN_TOO_BIG_COORDINATES); - public static final String COMMAND_SET_SERVER_SPAWN_SUCCESSFULLY_SET = renderTranslation(Keys.COMMAND_SET_SERVER_SPAWN_SUCCESSFULLY_SET); - public static final String DISCORD_SERVER_ENABLED = renderTranslation(Keys.DISCORD_SERVER_ENABLED); - public static final String DISCORD_SERVER_DISABLED = renderTranslation(Keys.DISCORD_SERVER_DISABLED); - public static final String DISCORD_BOT_STATUS = renderTranslation(Keys.DISCORD_BOT_STATUS); - public static final String DISCORD_NOT_A_USER = renderTranslation(Keys.DISCORD_NOT_A_USER); - public static final String DISCORD_NO_CODE = renderTranslation(Keys.DISCORD_NO_CODE); - public static final String DISCORD_INVALID_CODE = renderTranslation(Keys.DISCORD_INVALID_CODE); - public static final String DISCORD_CODE_ATTEMPTS_LIMIT_REACHED = renderTranslation(Keys.DISCORD_CODE_ATTEMPTS_LIMIT_REACHED); - public static final String DISCORD_MESSAGE_ATTEMPTS_LIMIT_REACHED = renderTranslation(Keys.DISCORD_MESSAGE_ATTEMPTS_LIMIT_REACHED); - public static final String DISCORD_UNKNOWN_COMMAND = renderTranslation(Keys.DISCORD_UNKNOWN_COMMAND); - public static final String DISCORD_NOT_LINKED = renderTranslation(Keys.DISCORD_NOT_LINKED); - public static final String DISCORD_ALREADY_LINKED = renderTranslation(Keys.DISCORD_ALREADY_LINKED); - public static final String DISCORD_SUCCESSFULLY_LINKED = renderTranslation(Keys.DISCORD_SUCCESSFULLY_LINKED); - public static final String DISCORD_BANNED = renderTranslation(Keys.DISCORD_BANNED); - public static final String DISCORD_UNBANNED = renderTranslation(Keys.DISCORD_UNBANNED); - public static final String DISCORD_MUTED = renderTranslation(Keys.DISCORD_MUTED); - public static final String DISCORD_UNMUTED = renderTranslation(Keys.DISCORD_UNMUTED); - public static final String DISCORD_EMBED_TITLE = renderTranslation(Keys.DISCORD_EMBED_TITLE); - public static final String DISCORD_SKIN_SERVICE_UNAVAILABLE = renderTranslation(Keys.DISCORD_SKIN_SERVICE_UNAVAILABLE); - public static final String DISCORD_SKIN_ONLY_ONE_IMG = renderTranslation(Keys.DISCORD_SKIN_ONLY_ONE_IMG); - public static final String DISCORD_SKIN_INVALID_IMG = renderTranslation(Keys.DISCORD_SKIN_INVALID_IMG); - public static final String DISCORD_SKIN_TOO_MANY_SKINS = renderTranslation(Keys.DISCORD_SKIN_TOO_MANY_SKINS); - public static final String DISCORD_SKIN_ALREADY_SET = renderTranslation(Keys.DISCORD_SKIN_ALREADY_SET); - public static final String DISCORD_SKIN_VARIANT_YES = renderTranslation(Keys.DISCORD_SKIN_VARIANT_YES); - public static final String DISCORD_SKIN_VARIANT_NO = renderTranslation(Keys.DISCORD_SKIN_VARIANT_NO); - public static final String DISCORD_SKIN_VARIANT_NO_REPLY = renderTranslation(Keys.DISCORD_SKIN_VARIANT_NO_REPLY); - public static final String DISCORD_SKIN_INVALID_NAME_REGEX = renderTranslation(Keys.DISCORD_SKIN_INVALID_NAME_REGEX); - public static final String DISCORD_SKIN_NO_NAME = renderTranslation(Keys.DISCORD_SKIN_NO_NAME); - public static final String DISCORD_SKIN_LIST_OF_SKINS = renderTranslation(Keys.DISCORD_SKIN_LIST_OF_SKINS); - public static final String DISCORD_SKIN_LIST_OF_SKIN_ACTIONS = renderTranslation(Keys.DISCORD_SKIN_LIST_OF_SKIN_ACTIONS); - public static final String DISCORD_SKIN_ACTION_EDIT_INFO = renderTranslation(Keys.DISCORD_SKIN_ACTION_EDIT_INFO); - public static final String DISCORD_SKIN_ACTION_RENAME_INFO = renderTranslation(Keys.DISCORD_SKIN_ACTION_RENAME_INFO); - public static final String DISCORD_SKIN_INVALID_INDEX = renderTranslation(Keys.DISCORD_SKIN_INVALID_INDEX); - public static final String DISCORD_SKIN_SUCCESSFULLY_ADDED = renderTranslation(Keys.DISCORD_SKIN_SUCCESSFULLY_ADDED); - public static final String DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT = renderTranslation(Keys.DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT); - public static final String DISCORD_SKIN_EDIT_ALREADY_SET = renderTranslation(Keys.DISCORD_SKIN_EDIT_ALREADY_SET); - public static final String DISCORD_SKIN_SUCCESSFULLY_EDITED = renderTranslation(Keys.DISCORD_SKIN_SUCCESSFULLY_EDITED); - public static final String DISCORD_SKIN_SUCCESSFULLY_EDITED_MINECRAFT = renderTranslation(Keys.DISCORD_SKIN_SUCCESSFULLY_EDITED_MINECRAFT); - public static final String DISCORD_SKIN_SUCCESSFULLY_REMOVED = renderTranslation(Keys.DISCORD_SKIN_SUCCESSFULLY_REMOVED); - public static final String DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT = renderTranslation(Keys.DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT); - public static final String DISCORD_SKIN_SUCCESSFULLY_RENAMED = renderTranslation(Keys.DISCORD_SKIN_SUCCESSFULLY_RENAMED); - public static final String DISCORD_SKIN_SUCCESSFULLY_RENAMED_MINECRAFT = renderTranslation(Keys.DISCORD_SKIN_SUCCESSFULLY_RENAMED_MINECRAFT); - public static final String DISCORD_COMMAND_LIST_OF_SKINS = renderTranslation(Keys.DISCORD_COMMAND_LIST_OF_SKINS); - public static final String DISCORD_COMMAND_SKIN_NOT_FOUND = renderTranslation(Keys.DISCORD_COMMAND_SKIN_NOT_FOUND); - public static final String DISCORD_COMMAND_INVALID_ARGUMENTS = renderTranslation(Keys.DISCORD_COMMAND_INVALID_ARGUMENTS); - public static final String MENU_SKINS_TITLE = renderTranslation(Keys.MENU_SKINS_TITLE); - public static final String MENU_SKINS_BUTTON_APPLY = renderTranslation(Keys.MENU_SKINS_BUTTON_APPLY); - public static final String MENU_SKINS_BUTTON_DELETE = renderTranslation(Keys.MENU_SKINS_BUTTON_DELETE); - public static final String MENU_SKINS_BUTTON_QUIT = renderTranslation(Keys.MENU_SKINS_BUTTON_QUIT); - public static final String MENU_DISCORD_TITLE = renderTranslation(Keys.MENU_DISCORD_TITLE); - public static final String MENU_DISCORD_NUMBERS_0 = renderTranslation(Keys.MENU_DISCORD_NUMBERS_0); - public static final String MENU_DISCORD_NUMBERS_1 = renderTranslation(Keys.MENU_DISCORD_NUMBERS_1); - public static final String MENU_DISCORD_NUMBERS_2 = renderTranslation(Keys.MENU_DISCORD_NUMBERS_2); - public static final String MENU_DISCORD_NUMBERS_3 = renderTranslation(Keys.MENU_DISCORD_NUMBERS_3); - public static final String MENU_DISCORD_NUMBERS_4 = renderTranslation(Keys.MENU_DISCORD_NUMBERS_4); - public static final String MENU_DISCORD_NUMBERS_5 = renderTranslation(Keys.MENU_DISCORD_NUMBERS_5); - public static final String MENU_DISCORD_NUMBERS_6 = renderTranslation(Keys.MENU_DISCORD_NUMBERS_6); - public static final String MENU_DISCORD_NUMBERS_7 = renderTranslation(Keys.MENU_DISCORD_NUMBERS_7); - public static final String MENU_DISCORD_NUMBERS_8 = renderTranslation(Keys.MENU_DISCORD_NUMBERS_8); - public static final String MENU_DISCORD_NUMBERS_9 = renderTranslation(Keys.MENU_DISCORD_NUMBERS_9); - public static final String MENU_CRAFTS_CATEGORIES_TITLE = renderTranslation(Keys.MENU_CRAFTS_CATEGORIES_TITLE); - public static final String MENU_CRAFTS_CATEGORY_TITLE = renderTranslation(Keys.MENU_CRAFTS_CATEGORY_TITLE); - public static final String MENU_CRAFTS_CRAFT_TITLE = renderTranslation(Keys.MENU_CRAFTS_CRAFT_TITLE); - public static final String MENU_CRAFTS_BUTTON_PREVIOUS_PAGE = renderTranslation(Keys.MENU_CRAFTS_BUTTON_PREVIOUS_PAGE); - public static final String MENU_CRAFTS_BUTTON_NEXT_PAGE = renderTranslation(Keys.MENU_CRAFTS_BUTTON_NEXT_PAGE); - public static final String MENU_PRONOUNS_TITLE = renderTranslation(Keys.MENU_PRONOUNS_TITLE); - public static final String MENU_PRONOUNS_BUTTON_HE_TITLE = renderTranslation(Keys.MENU_PRONOUNS_BUTTON_HE_TITLE); - public static final String MENU_PRONOUNS_BUTTON_HE_LORE = renderTranslation(Keys.MENU_PRONOUNS_BUTTON_HE_LORE); - public static final String MENU_PRONOUNS_BUTTON_SHE_TITLE = renderTranslation(Keys.MENU_PRONOUNS_BUTTON_SHE_TITLE); - public static final String MENU_PRONOUNS_BUTTON_SHE_LORE = renderTranslation(Keys.MENU_PRONOUNS_BUTTON_SHE_LORE); - public static final String MENU_PRONOUNS_BUTTON_THEY_TITLE = renderTranslation(Keys.MENU_PRONOUNS_BUTTON_THEY_TITLE); - public static final String MENU_PRONOUNS_BUTTON_THEY_LORE = renderTranslation(Keys.MENU_PRONOUNS_BUTTON_THEY_LORE); - public static final String MENU_RESOURCE_PACK_TITLE = renderTranslation(Keys.MENU_RESOURCE_PACK_TITLE); - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_TITLE = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_TITLE); - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_LORE_0 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_LORE_0); - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_LORE_1 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_LORE_1); - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_LORE_2 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_LORE_2); - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_LORE_3 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_LORE_3); - public static final String MENU_RESOURCE_PACK_BUTTON_INFO_LORE_4 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_INFO_LORE_4); - public static final String MENU_RESOURCE_PACK_BUTTON_NONE_TITLE = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_NONE_TITLE); - public static final String MENU_RESOURCE_PACK_BUTTON_NONE_LORE_0 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_NONE_LORE_0); - public static final String MENU_RESOURCE_PACK_BUTTON_NONE_LORE_1 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_NONE_LORE_1); - public static final String MENU_RESOURCE_PACK_BUTTON_NONE_KICK_TITLE = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_NONE_KICK_TITLE); - public static final String MENU_RESOURCE_PACK_BUTTON_NONE_KICK_SUBTITLE = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_NONE_KICK_SUBTITLE); - public static final String MENU_RESOURCE_PACK_BUTTON_LITE_TITLE = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_LITE_TITLE); - public static final String MENU_RESOURCE_PACK_BUTTON_LITE_LORE_0 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_LITE_LORE_0); - public static final String MENU_RESOURCE_PACK_BUTTON_LITE_LORE_1 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_LITE_LORE_1); - public static final String MENU_RESOURCE_PACK_BUTTON_LITE_LORE_2 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_LITE_LORE_2); - public static final String MENU_RESOURCE_PACK_BUTTON_LITE_LORE_3 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_LITE_LORE_3); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_TITLE = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_TITLE); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_0 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_0); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_1 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_1); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_2 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_2); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_3 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_3); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_4 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_4); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_5 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_5); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_6 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_6); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_7 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_7); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_8 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_8); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_9 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_9); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_10 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_10); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_11 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_11); - public static final String MENU_RESOURCE_PACK_BUTTON_FULL_LORE_12 = renderTranslation(Keys.MENU_RESOURCE_PACK_BUTTON_FULL_LORE_12); - public static final String MENU_RENAMES_TITLE = renderTranslation(Keys.MENU_RENAMES_TITLE); - public static final String MENU_RENAMES_BUTTON_PREVIOUS_PAGE = renderTranslation(Keys.MENU_RENAMES_BUTTON_PREVIOUS_PAGE); - public static final String MENU_RENAMES_BUTTON_NEXT_PAGE = renderTranslation(Keys.MENU_RENAMES_BUTTON_NEXT_PAGE); - public static final String MENU_RENAME_TITLE = renderTranslation(Keys.MENU_RENAME_TITLE); - public static final String MENU_RENAME_NO_EXP = renderTranslation(Keys.MENU_RENAME_NO_EXP); - public static final String REGISTRATION_ANONYMOUS_NAME = renderTranslation(Keys.REGISTRATION_ANONYMOUS_NAME); - public static final String REGISTRATION_ONLY_CYRILLIC = renderTranslation(Keys.REGISTRATION_ONLY_CYRILLIC); - public static final String REGISTRATION_SIGN_FIRST_NAME_0 = renderTranslation(Keys.REGISTRATION_SIGN_FIRST_NAME_0); - public static final String REGISTRATION_SIGN_FIRST_NAME_1 = renderTranslation(Keys.REGISTRATION_SIGN_FIRST_NAME_1); - public static final String REGISTRATION_SIGN_FIRST_NAME_2 = renderTranslation(Keys.REGISTRATION_SIGN_FIRST_NAME_2); - public static final String REGISTRATION_SIGN_FIRST_NAME_3 = renderTranslation(Keys.REGISTRATION_SIGN_FIRST_NAME_3); - public static final String REGISTRATION_SIGN_LAST_NAME_0 = renderTranslation(Keys.REGISTRATION_SIGN_LAST_NAME_0); - public static final String REGISTRATION_SIGN_LAST_NAME_1 = renderTranslation(Keys.REGISTRATION_SIGN_LAST_NAME_1); - public static final String REGISTRATION_SIGN_LAST_NAME_2 = renderTranslation(Keys.REGISTRATION_SIGN_LAST_NAME_2); - public static final String REGISTRATION_SIGN_LAST_NAME_3 = renderTranslation(Keys.REGISTRATION_SIGN_LAST_NAME_3); - public static final String REGISTRATION_SIGN_PATRONYMIC_0 = renderTranslation(Keys.REGISTRATION_SIGN_PATRONYMIC_0); - public static final String REGISTRATION_SIGN_PATRONYMIC_1 = renderTranslation(Keys.REGISTRATION_SIGN_PATRONYMIC_1); - public static final String REGISTRATION_SIGN_PATRONYMIC_2 = renderTranslation(Keys.REGISTRATION_SIGN_PATRONYMIC_2); - public static final String REGISTRATION_SIGN_PATRONYMIC_3 = renderTranslation(Keys.REGISTRATION_SIGN_PATRONYMIC_3); - public static final String REGISTRATION_MESSAGE_0 = renderTranslation(Keys.REGISTRATION_MESSAGE_0); - public static final String REGISTRATION_MESSAGE_1 = renderTranslation(Keys.REGISTRATION_MESSAGE_1); - public static final String REGISTRATION_MESSAGE_2 = renderTranslation(Keys.REGISTRATION_MESSAGE_2); - public static final String REGISTRATION_MESSAGE_3 = renderTranslation(Keys.REGISTRATION_MESSAGE_3); - public static final String REGISTRATION_MESSAGE_4 = renderTranslation(Keys.REGISTRATION_MESSAGE_4); - public static final String REGISTRATION_MESSAGE_5 = renderTranslation(Keys.REGISTRATION_MESSAGE_5); - public static final String REGISTRATION_MESSAGE_6 = renderTranslation(Keys.REGISTRATION_MESSAGE_6); - public static final String REGISTRATION_MESSAGE_7 = renderTranslation(Keys.REGISTRATION_MESSAGE_7); - public static final String REGISTRATION_MESSAGE_8 = renderTranslation(Keys.REGISTRATION_MESSAGE_8); - public static final String REGISTRATION_MESSAGE_9 = renderTranslation(Keys.REGISTRATION_MESSAGE_9); - public static final String REGISTRATION_MESSAGE_10 = renderTranslation(Keys.REGISTRATION_MESSAGE_10); - public static final String REGISTRATION_MESSAGE_11 = renderTranslation(Keys.REGISTRATION_MESSAGE_11); - public static final String REGISTRATION_MESSAGE_12 = renderTranslation(Keys.REGISTRATION_MESSAGE_12); - public static final String REGISTRATION_MESSAGE_13 = renderTranslation(Keys.REGISTRATION_MESSAGE_13); - public static final String REGISTRATION_MESSAGE_14 = renderTranslation(Keys.REGISTRATION_MESSAGE_14); - public static final String REGISTRATION_MESSAGE_15 = renderTranslation(Keys.REGISTRATION_MESSAGE_15); - public static final String REGISTRATION_MESSAGE_16 = renderTranslation(Keys.REGISTRATION_MESSAGE_16); - public static final String REGISTRATION_MESSAGE_17 = renderTranslation(Keys.REGISTRATION_MESSAGE_17); - public static final String CHAT_HOVER_NAME = renderTranslation(Keys.CHAT_HOVER_NAME); - public static final String CHAT_HOVER_MESSAGE = renderTranslation(Keys.CHAT_HOVER_MESSAGE); - public static final String CHAT_LOCAL_FORMAT = renderTranslation(Keys.CHAT_LOCAL_FORMAT); - public static final String CHAT_GLOBAL_FORMAT = renderTranslation(Keys.CHAT_GLOBAL_FORMAT); - public static final String CHAT_PRIVATE_FORMAT_GLOBAL = renderTranslation(Keys.CHAT_PRIVATE_FORMAT_GLOBAL); - public static final String CHAT_PRIVATE_FORMAT_SENDER = renderTranslation(Keys.CHAT_PRIVATE_FORMAT_SENDER); - public static final String CHAT_PRIVATE_FORMAT_RECEIVER = renderTranslation(Keys.CHAT_PRIVATE_FORMAT_RECEIVER); - public static final String CHAT_DISCORD_FORMAT = renderTranslation(Keys.CHAT_DISCORD_FORMAT); - public static final String CHAT_DISCORD_FORMAT_REPLYING = renderTranslation(Keys.CHAT_DISCORD_FORMAT_REPLYING); - public static final String CHAT_DISCORD_FORMAT_GLOBAL_TO_LOCAL = renderTranslation(Keys.CHAT_DISCORD_FORMAT_GLOBAL_TO_LOCAL); - public static final String CHAT_DISCORD_FORMAT_GLOBAL_TO_GLOBAL = renderTranslation(Keys.CHAT_DISCORD_FORMAT_GLOBAL_TO_GLOBAL); - public static final String CHAT_DISCORD_ATTACHMENT = renderTranslation(Keys.CHAT_DISCORD_ATTACHMENT); - public static final String CHAT_DISCORD_ATTACHMENTS = renderTranslation(Keys.CHAT_DISCORD_ATTACHMENTS); - public static final String CHAT_ME_FORMAT = renderTranslation(Keys.CHAT_ME_FORMAT); - public static final String CHAT_DO_FORMAT = renderTranslation(Keys.CHAT_DO_FORMAT); - public static final String CHAT_IT_FORMAT = renderTranslation(Keys.CHAT_IT_FORMAT); - public static final String CHAT_TO_DO_FORMAT = renderTranslation(Keys.CHAT_TO_DO_FORMAT); - public static final String CHAT_TRY_FORMAT = renderTranslation(Keys.CHAT_TRY_FORMAT); - public static final String CHAT_DEATH_FORMAT_UNO = renderTranslation(Keys.CHAT_DEATH_FORMAT_UNO); - public static final String CHAT_DEATH_FORMAT_DUO = renderTranslation(Keys.CHAT_DEATH_FORMAT_DUO); - public static final String CHAT_JOIN_FORMAT = renderTranslation(Keys.CHAT_JOIN_FORMAT); - public static final String CHAT_QUIT_FORMAT = renderTranslation(Keys.CHAT_QUIT_FORMAT); - public static final String PLAYER_NAME_NICKNAME = renderTranslation(Keys.PLAYER_NAME_NICKNAME); - public static final String PLAYER_NAME_FIRST_NAME = renderTranslation(Keys.PLAYER_NAME_FIRST_NAME); - public static final String PLAYER_NAME_LAST_NAME = renderTranslation(Keys.PLAYER_NAME_LAST_NAME); - public static final String PLAYER_NAME_PATRONYMIC = renderTranslation(Keys.PLAYER_NAME_PATRONYMIC); - public static final String PLAYER_PRONOUNS_HE_JOIN = renderTranslation(Keys.PLAYER_PRONOUNS_HE_JOIN); - public static final String PLAYER_PRONOUNS_HE_QUIT = renderTranslation(Keys.PLAYER_PRONOUNS_HE_QUIT); - public static final String PLAYER_PRONOUNS_HE_SPIT = renderTranslation(Keys.PLAYER_PRONOUNS_HE_SPIT); - public static final String PLAYER_PRONOUNS_HE_FART = renderTranslation(Keys.PLAYER_PRONOUNS_HE_FART); - public static final String PLAYER_PRONOUNS_HE_PRONOUNS = renderTranslation(Keys.PLAYER_PRONOUNS_HE_PRONOUNS); - public static final String PLAYER_PRONOUNS_HE_TRAVELER = renderTranslation(Keys.PLAYER_PRONOUNS_HE_TRAVELER); - public static final String PLAYER_PRONOUNS_HE_SIT = renderTranslation(Keys.PLAYER_PRONOUNS_HE_SIT); - public static final String PLAYER_PRONOUNS_HE_GET_UP = renderTranslation(Keys.PLAYER_PRONOUNS_HE_GET_UP); - public static final String PLAYER_PRONOUNS_HE_DEATH = renderTranslation(Keys.PLAYER_PRONOUNS_HE_DEATH); - public static final String PLAYER_PRONOUNS_HE_KILL = renderTranslation(Keys.PLAYER_PRONOUNS_HE_KILL); - public static final String PLAYER_PRONOUNS_HE_SAID = renderTranslation(Keys.PLAYER_PRONOUNS_HE_SAID); - public static final String PLAYER_PRONOUNS_SHE_JOIN = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_JOIN); - public static final String PLAYER_PRONOUNS_SHE_QUIT = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_QUIT); - public static final String PLAYER_PRONOUNS_SHE_SPIT = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_SPIT); - public static final String PLAYER_PRONOUNS_SHE_FART = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_FART); - public static final String PLAYER_PRONOUNS_SHE_PRONOUNS = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_PRONOUNS); - public static final String PLAYER_PRONOUNS_SHE_TRAVELER = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_TRAVELER); - public static final String PLAYER_PRONOUNS_SHE_SIT = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_SIT); - public static final String PLAYER_PRONOUNS_SHE_GET_UP = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_GET_UP); - public static final String PLAYER_PRONOUNS_SHE_DEATH = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_DEATH); - public static final String PLAYER_PRONOUNS_SHE_KILL = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_KILL); - public static final String PLAYER_PRONOUNS_SHE_SAID = renderTranslation(Keys.PLAYER_PRONOUNS_SHE_SAID); - public static final String PLAYER_PRONOUNS_THEY_JOIN = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_JOIN); - public static final String PLAYER_PRONOUNS_THEY_QUIT = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_QUIT); - public static final String PLAYER_PRONOUNS_THEY_SPIT = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_SPIT); - public static final String PLAYER_PRONOUNS_THEY_FART = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_FART); - public static final String PLAYER_PRONOUNS_THEY_PRONOUNS = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_PRONOUNS); - public static final String PLAYER_PRONOUNS_THEY_TRAVELER = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_TRAVELER); - public static final String PLAYER_PRONOUNS_THEY_SIT = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_SIT); - public static final String PLAYER_PRONOUNS_THEY_GET_UP = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_GET_UP); - public static final String PLAYER_PRONOUNS_THEY_DEATH = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_DEATH); - public static final String PLAYER_PRONOUNS_THEY_KILL = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_KILL); - public static final String PLAYER_PRONOUNS_THEY_SAID = renderTranslation(Keys.PLAYER_PRONOUNS_THEY_SAID); - // - - @Contract(" -> fail") - private Strings() throws AssertionError { - throw new AssertionError("Utility class"); - } - } -} diff --git a/src/main/java/com/minersstudios/mscore/listener/api/event/EventListener.java b/src/main/java/com/minersstudios/mscore/listener/api/event/EventListener.java index 13b758c1..a7ed2921 100644 --- a/src/main/java/com/minersstudios/mscore/listener/api/event/EventListener.java +++ b/src/main/java/com/minersstudios/mscore/listener/api/event/EventListener.java @@ -1,9 +1,6 @@ package com.minersstudios.mscore.listener.api.event; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * All event listeners annotated using {@link EventListener} will be registered @@ -11,6 +8,7 @@ * * @see AbstractEventListener */ +@Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface EventListener {} diff --git a/src/main/java/com/minersstudios/mscore/listener/api/packet/PacketListener.java b/src/main/java/com/minersstudios/mscore/listener/api/packet/PacketListener.java index 5561d572..5cc59789 100644 --- a/src/main/java/com/minersstudios/mscore/listener/api/packet/PacketListener.java +++ b/src/main/java/com/minersstudios/mscore/listener/api/packet/PacketListener.java @@ -2,18 +2,16 @@ import com.minersstudios.mscore.listener.api.event.AbstractEventListener; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * All packet listeners annotated using {@link PacketListener} will be * registered automatically. Also, it must be extended by - * {@link AbstractEventListener} + * {@link AbstractEventListener}. * * @see AbstractEventListener */ +@Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface PacketListener {} diff --git a/src/main/java/com/minersstudios/mscore/listener/impl/event/server/ServerCommandListener.java b/src/main/java/com/minersstudios/mscore/listener/impl/event/server/ServerCommandListener.java index ebd2b336..5fa14ff2 100644 --- a/src/main/java/com/minersstudios/mscore/listener/impl/event/server/ServerCommandListener.java +++ b/src/main/java/com/minersstudios/mscore/listener/impl/event/server/ServerCommandListener.java @@ -1,7 +1,7 @@ package com.minersstudios.mscore.listener.impl.event.server; import com.minersstudios.mscore.MSCore; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.listener.api.event.AbstractEventListener; import com.minersstudios.mscore.listener.api.event.EventListener; import com.minersstudios.mscore.plugin.MSLogger; @@ -23,7 +23,7 @@ public void onServerCommand(final @NotNull ServerCommandEvent event) { if (ONLY_PLAYER_COMMAND_SET.contains(command)) { MSLogger.severe( event.getSender(), - LanguageRegistry.Components.ERROR_ONLY_PLAYER_COMMAND + Translations.ERROR_ONLY_PLAYER_COMMAND.asTranslatable() ); event.setCancelled(true); } diff --git a/src/main/java/com/minersstudios/mscore/locale/LanguageFile.java b/src/main/java/com/minersstudios/mscore/locale/LanguageFile.java new file mode 100644 index 00000000..2cfa3132 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/locale/LanguageFile.java @@ -0,0 +1,497 @@ +package com.minersstudios.mscore.locale; + +import com.google.common.base.Joiner; +import com.google.gson.JsonIOException; +import com.google.gson.JsonSyntaxException; +import com.minersstudios.mscore.locale.resource.GitHubTranslationResourceManager; +import com.minersstudios.mscore.locale.resource.TranslationResourceManager; +import com.minersstudios.mscore.locale.resource.URITranslationResourceManager; +import com.minersstudios.mscore.plugin.MSLogger; +import com.minersstudios.mscore.resource.github.Tag; +import com.minersstudios.mscore.utility.ChatUtils; +import com.minersstudios.mscore.utility.SharedConstants; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import net.kyori.adventure.translation.Translator; +import net.minecraft.locale.Language; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; +import org.jetbrains.annotations.*; + +import javax.annotation.concurrent.Immutable; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +import static java.util.concurrent.CompletableFuture.failedFuture; + +/** + * Represents a language file containing translations for a specific locale. + *
+ * Language file can be created with a couple of static methods : + *
    + *
  • {@link #fromResource(Locale, TranslationResourceManager)}
  • + *
  • {@link #fromStream(Locale, InputStream)}
  • + *
+ */ +@Immutable +public final class LanguageFile { + private final Locale locale; + private final Map translationMap; + + private static final String JSON_EXTENSION = ".json"; + + // + private static final String KEY_URL = "url"; + private static final String KEY_TOKEN = "token"; + private static final String KEY_USER = "user"; + private static final String KEY_REPO = "repo"; + private static final String KEY_TAG = "tag"; + private static final String KEY_FOLDER_PATH = "folder-path"; + // + + private LanguageFile(final @NotNull Locale locale) { + this.locale = locale; + this.translationMap = new Object2ObjectOpenHashMap<>(); + } + + /** + * Returns the locale of this language file + * + * @return The locale of this language file + */ + public @NotNull Locale getLocale() { + return this.locale; + } + + /** + * Returns the unmodifiable map of translations in this language file + * + * @return The unmodifiable map of translations in this language file + */ + public @NotNull @Unmodifiable Map getTranslationMap() { + return Collections.unmodifiableMap(this.translationMap); + } + + /** + * Gets the translation for the given key + * + * @param key The key to get the translation for + * @return The translation for the given key, or null if it doesn't exist + */ + public @Nullable String get(final @NotNull String key) { + return this.getOrDefault(key, null); + } + + /** + * Gets the translation for the given key, or the fallback if it doesn't + * exist + * + * @param key The key to get the translation for + * @param fallback The fallback to return if the translation doesn't exist + * @return The translation for the given key, or the fallback if it doesn't + * exist + */ + public @UnknownNullability String getOrDefault( + final @NotNull String key, + final @Nullable String fallback + ) { + return this.translationMap.getOrDefault(key, fallback); + } + + /** + * Returns the number of translations in this language file + * + * @return The number of translations in this language file + */ + public int size() { + return this.translationMap.size(); + } + + /** + * Returns a hash code based on the locale and translations + * + * @return A hash code based on the locale and translations + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + + result = prime * result + this.locale.hashCode(); + result = prime * result + this.translationMap.hashCode(); + + return result; + } + + /** + * Compares the specified object with this language file for equality + * + * @param obj The object to compare + * @return True if the object is a language file and has the same locale and + * translations + */ + @Contract("null -> false") + @Override + public boolean equals(final @Nullable Object obj) { + return this == obj + || ( + obj instanceof LanguageFile that + && this.locale.equals(that.locale) + && this.translationMap.equals(that.translationMap) + ); + } + + /** + * Checks whether the given key exists in this language file + * + * @param key The key to check for + * @return Whether the given key exists in this language file + */ + public boolean containsKey(final @NotNull String key) { + return this.translationMap.containsKey(key); + } + + /** + * Returns whether this language file contains the given translation + * + * @param translation The translation to check for + * @return True if this language file contains the given translation + */ + public boolean containsTranslation(final @NotNull String translation) { + return this.translationMap.containsValue(translation); + } + + /** + * Returns whether this language file contains no translations + * + * @return True if this language file contains no translations + */ + public boolean isEmpty() { + return this.translationMap.isEmpty(); + } + + /** + * Returns a string representation of this language file + * + * @return A string representation of this language file containing the + * translations + */ + @Override + public @NotNull String toString() { + return "LanguageFile{" + + "locale=" + this.locale + + ", translations=[" + Joiner.on(", ").withKeyValueSeparator("=").join(this.translationMap) + ']' + + '}'; + } + + /** + * Creates and loads all languages from the given configuration section. + *
+ * Completes exceptionally with : + *
    + *
  • {@link IllegalStateException} - If the locale cannot be parsed + * or the URL or user and repository + * are not specified
  • + *
  • {@link JsonIOException} - If the file cannot be read
  • + *
  • {@link JsonSyntaxException} - If the file is not a valid JSON + * file
  • + *
+ * + * Example of a configuration section : + *
+     * languages:
+     *   en_us: '' # Loads from the file
+     *   en_gb:
+     *     url: https:\\example.com\en_us.json
+     *   uk_ua:
+     *     user: ExampleUser
+     *     repo: ConfigRepo
+     *     tag: v1.0
+     *     token: ~some-github-token~
+     *     folder-path: lang
+     * 
+ * + * @param file The configuration file + * @param config The yaml configuration + * @param section The configuration section + * @param onLoaded The consumer to accept the loaded language file if the + * language file was loaded successfully + * @param onFailed The consumer to accept the key and the exception if the + * language file failed to load + * @return A map containing the language keys and their respective + * completable futures of language files + * @see #fromResource(Locale, TranslationResourceManager) + * @see #fromSection(File, YamlConfiguration, ConfigurationSection) + */ + public static @NotNull Map> allFromSection( + final @NotNull File file, + final @NotNull YamlConfiguration config, + final @NotNull ConfigurationSection section, + final @Nullable Consumer onLoaded, + final @Nullable BiConsumer onFailed + ) { + final var keySet = section.getKeys(false); + final var futureMap = new Object2ObjectOpenHashMap>(keySet.size()); + + for (final var key : keySet) { + final ConfigurationSection langSection = section.getConfigurationSection(key); + CompletableFuture future; + + if (langSection == null) { + final Locale locale = Translator.parseLocale(key); + + if (locale == null) { + MSLogger.warning("Failed to parse locale: " + key); + + continue; + } + + try { + future = CompletableFuture.completedFuture( + fromResource( + locale, + TranslationResourceManager.file(getFile(key)) + ) + ); + } catch (final Throwable e) { + future = failedFuture(e); + } + } else { + future = fromSection(file, config, langSection); + } + + futureMap.put( + key, + future + .thenApply( + languageFile -> { + if (onLoaded != null) { + onLoaded.accept(languageFile); + } + + return languageFile; + } + ) + .exceptionallyCompose( + throwable -> { + if (onFailed != null) { + onFailed.accept(key, throwable); + } + + return failedFuture(throwable); + } + ) + ); + } + + return futureMap; + } + + /** + * Creates and loads a new language file from the given locale and + * configuration section. + *
+ * Completes exceptionally with : + *
    + *
  • {@link IllegalStateException} - If the locale cannot be parsed, + * or the URL or user and repository + * are not specified
  • + *
  • {@link JsonIOException} - If the file cannot be read
  • + *
  • {@link JsonSyntaxException} - If the file is not a valid JSON + * file
  • + *
+ * + * Configuration sections example : + *
+     * en_us:
+     *   url: https:\\example.com\en_us.json
+     * uk_ua:
+     *   user: ExampleUser
+     *   repo: ConfigRepo
+     *   tag: v1.0
+     *   token: ~some-github-token~
+     *   folder-path: lang
+     * 
+ * + * @param file The configuration file + * @param config The yaml configuration + * @param section The configuration section + * @return A future containing the language file + * @see #fromURI(Locale, URITranslationResourceManager) + * @see #fromGitHub(Locale, GitHubTranslationResourceManager) + */ + public static @NotNull CompletableFuture fromSection( + final @NotNull File file, + final @NotNull YamlConfiguration config, + final @NotNull ConfigurationSection section + ) { + final String localeCode = section.getName(); + final Locale locale = Translator.parseLocale(localeCode); + + if (locale == null) { + return failedFuture(new IllegalStateException("Failed to parse locale: " + localeCode)); + } + + final String url = section.getString(KEY_URL); + + if (ChatUtils.isNotBlank(url)) { + return fromURI( + locale, + TranslationResourceManager.url(url) + ); + } + + final String user = section.getString(KEY_USER); + final String repo = section.getString(KEY_REPO); + + if ( + ChatUtils.isBlank(user) + || ChatUtils.isBlank(repo) + ) { + return failedFuture(new IllegalStateException("Specify the URL or user and repository for : " + section)); + } + + final GitHubTranslationResourceManager resourceManager = + TranslationResourceManager.github( + getFile(localeCode), + user, + repo, + section.getString(KEY_TAG), + section.getString(KEY_TOKEN), + section.getString(KEY_FOLDER_PATH) + ); + + return fromGitHub(locale, resourceManager) + .thenApply(languageFile -> { + final Tag latestTag = resourceManager.getLatestTagNow(); + + if (latestTag != null) { + section.set(KEY_TAG, latestTag.getName()); + + synchronized (LanguageFile.class) { + try { + config.save(file); + } catch (final Throwable e) { + MSLogger.warning( + "Failed to save the configuration file: " + file, + e + ); + } + } + } + + return languageFile; + }); + } + + /** + * Creates and loads a new language file from the given locale and resource + * manager. + *
+ * Completes exceptionally with : + *
    + *
  • {@link JsonIOException} - If the file cannot be read
  • + *
  • {@link JsonSyntaxException} - If the file is not a valid JSON + * file
  • + *
+ * + * @param locale The locale of the language file + * @param resourceManager The resource manager of the language file + * @return A future containing the language file + * @see #fromResource(Locale, TranslationResourceManager) + */ + public static @NotNull CompletableFuture fromGitHub( + final @NotNull Locale locale, + final @NotNull GitHubTranslationResourceManager resourceManager + ) { + return resourceManager + .updateFile(false) + .thenApplyAsync(ignored -> fromResource(locale, resourceManager)); + } + + /** + * Creates and loads a new language file from the given locale and uri + * resource manager. + *
+ * Completes exceptionally with : + *
    + *
  • {@link JsonIOException} - If the file cannot be read
  • + *
  • {@link JsonSyntaxException} - If the file is not a valid JSON + * file
  • + *
+ * + * @param locale The locale of the language file + * @param resourceManager The resource manager of the language file + * @return A future containing the language file + * @see #fromResource(Locale, TranslationResourceManager) + */ + public static @NotNull CompletableFuture fromURI( + final @NotNull Locale locale, + final @NotNull URITranslationResourceManager resourceManager + ) { + return CompletableFuture.supplyAsync(() -> fromResource(locale, resourceManager)); + } + + /** + * Creates and loads a new language file from the given locale and resource + * manager + * + * @param locale The locale of the language file + * @param resourceManager The resource manager of the language file + * @return A future containing the language file + * @throws JsonIOException If the file cannot be read + * @throws JsonSyntaxException If the file is not a valid JSON file + * @see #fromStream(Locale, InputStream) + */ + public static @NotNull LanguageFile fromResource( + final @NotNull Locale locale, + final @NotNull TranslationResourceManager resourceManager + ) throws JsonIOException, JsonSyntaxException { + try (final var in = resourceManager.openStream()) { + return fromStream(locale, in); + } catch (final IOException e) { + throw new JsonIOException( + "Failed to read resource : " + resourceManager, + e + ); + } + } + + /** + * Creates and loads a new language file from the given locale and input + * stream + * + * @param locale The locale of the language file + * @param inputStream The input stream of the language file + * @return The language file + * @throws JsonIOException If the file cannot be read + * @throws JsonSyntaxException If the file is not a valid JSON file + */ + public static @NotNull LanguageFile fromStream( + final @NotNull Locale locale, + final @NotNull InputStream inputStream + ) throws JsonIOException, JsonSyntaxException { + final LanguageFile file = new LanguageFile(locale); + + try (inputStream) { + Language.loadFromJson( + inputStream, + file.translationMap::put + ); + } catch (final IOException e) { + throw new JsonIOException(e); + } + + return file; + } + + private static @NotNull File getFile(final @NotNull String path) { + return new File(SharedConstants.LANGUAGE_FOLDER_PATH, path + JSON_EXTENSION); + } +} diff --git a/src/main/java/com/minersstudios/mscore/locale/Translation.java b/src/main/java/com/minersstudios/mscore/locale/Translation.java new file mode 100644 index 00000000..ef0c86b1 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/locale/Translation.java @@ -0,0 +1,462 @@ +package com.minersstudios.mscore.locale; + +import com.google.common.collect.Maps; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.ComponentLike; +import net.kyori.adventure.text.TranslatableComponent; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnmodifiableView; + +import java.text.MessageFormat; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +import static com.minersstudios.mscore.locale.TranslationRegistry.registry; + +/** + * Represents a translation + */ +public final class Translation { + private final String key; + private final MessageFormat fallback; + private final Map map; + private final TranslatableComponent cachedTranslatable; + + Translation( + final @NotNull String key, + final @Nullable String fallback + ) { + this.key = key; + this.fallback = + new MessageFormat( + fallback == null + ? key + : fallback + ); + this.map = new ConcurrentHashMap<>(); + this.cachedTranslatable = + Component.translatable( + this.key, + this.fallback.toPattern() + ); + } + + /** + * Returns the key of this translation + * + * @return The key of this translation + */ + public @NotNull String getKey() { + return this.key; + } + + /** + * Returns the fallback of this translation + * + * @return The fallback of this translation, or the key if no fallback was + * specified + */ + public @NotNull MessageFormat getFallback() { + return this.fallback; + } + + /** + * Returns an unmodifiable view of the locale set + * + * @return An unmodifiable view of the locale set + */ + public @NotNull @UnmodifiableView Set localeSet() { + return Collections.unmodifiableSet(this.map.keySet()); + } + + /** + * Returns an unmodifiable view of the translations + * + * @return An unmodifiable view of the translations + */ + public @NotNull @UnmodifiableView Collection formats() { + return Collections.unmodifiableCollection(this.map.values()); + } + + /** + * Returns an unmodifiable view of the translation entries + * + * @return An unmodifiable view of the translation entries + */ + public @NotNull @UnmodifiableView Set> entrySet() { + return Collections.unmodifiableSet(this.map.entrySet()); + } + + /** + * Gets the translation for the given locale + * + * @param locale The locale to get the translation for + * @return The translation for the given locale, or the fallback if it + * doesn't exist + * @see #translate(Locale, String) + */ + public @NotNull MessageFormat translate(final @NotNull Locale locale) { + return this.translate(locale, null); + } + + /** + * Gets the translation for the given locale + * + * @param locale The locale to get the translation for + * @param fallback The fallback to return if the translation doesn't exist + * @return The translation for the given locale, or the fallback if it + * doesn't exist + * @see #translateNullable(Locale, String) + */ + public @NotNull MessageFormat translate( + final @NotNull Locale locale, + final @Nullable String fallback + ) { + final MessageFormat format = this.translateNullable(locale, fallback); + + return format == null + ? this.fallback + : format; + } + + /** + * Gets the translation for the given locale + * + * @param locale The locale to get the translation for + * @return The translation for the given locale + * @see #translateNullable(Locale, String) + */ + public @Nullable MessageFormat translateNullable(final @NotNull Locale locale) { + return this.translateNullable(locale, null); + } + + /** + * Gets the translation for the given locale + * + * @param locale The locale to get the translation for + * @param fallback The fallback to return if the translation doesn't exist + * @return The translation for the given locale, or the fallback if it + * doesn't exist + */ + public @Nullable MessageFormat translateNullable( + final @NotNull Locale locale, + final @Nullable String fallback + ) { + final MessageFormat format = this.map.get(locale); + + if (format == null) { + final MessageFormat defaultFormat = this.map.get(registry().getDefaultLocale()); + + return defaultFormat == null + ? ( + fallback == null + ? null + : new MessageFormat(fallback) + ) + : defaultFormat; + } + + return format; + } + + /** + * Returns the hash code of this translation + * + * @return The hash code of this translation + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + + result = prime * result + this.key.hashCode(); + result = prime * result + this.fallback.hashCode(); + result = prime * result + this.map.hashCode(); + result = prime * result + this.cachedTranslatable.hashCode(); + + return result; + } + + /** + * Returns whether this translation contains the given locale + * + * @param locale The locale to check + * @return Whether this translation contains the given locale + */ + @Contract("null -> false") + public boolean containsLocale(final @Nullable Locale locale) { + return locale != null + && this.map.containsKey(locale); + } + + /** + * Returns whether this translation contains the given format + * + * @param format The format to check + * @return Whether this translation contains the given format + */ + @Contract("null -> false") + public boolean containsFormat(final @Nullable MessageFormat format) { + return format != null + && this.map.containsValue(format); + } + + /** + * Returns whether this translation contains no translations + * + * @return Whether this translation contains no translations + */ + public boolean isEmpty() { + return this.map.isEmpty(); + } + + /** + * Returns whether the given object is equal to this translation + * + * @param obj The object to compare to + * @return Whether the given object is equal to this translation + */ + @Contract("null -> false") + @Override + public boolean equals(final @Nullable Object obj) { + return obj == this + || ( + obj instanceof final Translation that + && that.key.equals(this.key) + && that.fallback.equals(this.fallback) + && Maps.difference(that.map, this.map).areEqual() + && that.cachedTranslatable.equals(this.cachedTranslatable) + ); + } + + /** + * Returns a string representation of this translation + * + * @return A string representation of this translation + */ + @Override + public @NotNull String toString() { + final StringBuilder builder = new StringBuilder(); + + for (final var entry : this.map.entrySet()) { + builder + .append(entry.getKey()) + .append('=') + .append(entry.getValue().toPattern()) + .append(", "); + } + + if (!this.map.isEmpty()) { + builder.setLength(builder.length() - 2); + } + + return "Translation{" + + "key=" + this.key + + ", fallback=" + this.fallback + + ", translations=[" + builder + ']' + + '}'; + } + + /** + * Returns a translatable component representing this translation + * + * @return A translatable component representing this translation + */ + public @NotNull TranslatableComponent asTranslatable() { + return this.cachedTranslatable; + } + + /** + * Returns a translatable component representing this translation + * + * @param fallback The fallback to return if the translation doesn't exist + * @return A translatable component representing this translation + */ + @Contract("null -> new") + public @NotNull TranslatableComponent asTranslatable(final @Nullable String fallback) { + return fallback == null + ? this.cachedTranslatable + : Component.translatable(this.key, fallback); + } + + /** + * Returns a formatted translation + * + * @param args The arguments to format the translation with + * @return The formatted translation with the default locale and the given + * arguments + * @see #asString(Locale, Object...) + */ + public @NotNull String asString(final Object @NotNull ... args) { + return this.asString(registry().getDefaultLocale(), args); + } + + /** + * Returns a formatted translation + * + * @param locale The locale to format the translation with + * @param args The arguments to format the translation with + * @return The formatted translation with the given locale and the given + * arguments + * @see #asFormat(Locale) + */ + public @NotNull String asString( + final @NotNull Locale locale, + final Object @NotNull ... args + ) { + return this.asFormat(locale).format(args); + } + + /** + * Returns a message format representing this translation + * + * @return A message format representing this translation with the default + * locale + * @see #asFormat(Locale) + */ + public @NotNull MessageFormat asFormat() { + return this.asFormat(registry().getDefaultLocale()); + } + + /** + * Returns a message format representing this translation + * + * @param locale The locale to format the translation with + * @return A message format representing this translation with the given + * locale + */ + public @NotNull MessageFormat asFormat(final @NotNull Locale locale) { + return this.translate(locale); + } + + /** + * Returns a rendered component representing this translation + * + * @param args The arguments to format the translation with + * @return A component representing this translation with the default locale + * and the given arguments + * @see #asComponent(Locale, ComponentLike...) + */ + public @NotNull Component asComponent(final ComponentLike @NotNull ... args) { + return this.asComponent(registry().getDefaultLocale(), args); + } + + /** + * Returns a rendered component representing this translation + * + * @param locale The locale to format the translation with + * @param args The arguments to format the translation with + * @return A component representing this translation with the given locale + * and the given arguments + */ + public @NotNull Component asComponent( + final @NotNull Locale locale, + final ComponentLike @NotNull ... args + ) { + return registry().render( + this.asTranslatable().arguments(args), + locale + ); + } + + /** + * Registers the given translation for the given locale + * + * @param locale The locale to register the translation for + * @param translation The translation to register + */ + public void register( + final @NotNull Locale locale, + final @NotNull MessageFormat translation + ) { + this.map.put(locale, translation); + } + + /** + * Registers the given translations + * + * @param translations The translations to register + */ + public void registerAll(final @NotNull Map translations) { + this.map.putAll(translations); + } + + /** + * Unregisters the specified locale + * + * @param locale The locale to unregister + * @return Whether the locale was unregistered + */ + public boolean unregister(final @NotNull Locale locale) { + return this.map.remove(locale) != null; + } + + /** + * Unregisters the specified translation + * + * @param translation The translation to unregister + * @return Whether any translation was unregistered + */ + public boolean unregister(final @NotNull MessageFormat translation) { + boolean removed = false; + + for (final var entry : this.map.entrySet()) { + if (entry.getValue().equals(translation)) { + removed = true; + + this.map.remove(entry.getKey()); + } + } + + return removed; + } + + /** + * Unregisters the specified translation for the specified locale + * + * @param locale The locale to unregister + * @param translation The translation to unregister + * @return Whether the translation was unregistered + */ + public boolean unregister( + final @NotNull Locale locale, + final @NotNull MessageFormat translation + ) { + return this.map.remove(locale, translation); + } + + /** + * Unregisters all translations + */ + public void unregisterAll() { + this.map.clear(); + } + + /** + * Gets the translation for the given key from the translation registry + * + * @param key The key to get the translation for + * @return The translation for the given key, or key if it doesn't exist + * @see #of(String, String) + */ + public static @NotNull Translation of(final @NotNull String key) { + return of(key, null); + } + + /** + * Gets the translation for the given key from the translation registry + * + * @param key The key to get the translation for + * @param fallback The fallback to return if the translation doesn't exist + * @return The translation for the given key, or the fallback if it doesn't + * @see TranslationRegistry#getTranslation(String, String) + */ + public static @NotNull Translation of( + final @NotNull String key, + final @Nullable String fallback + ) { + return registry().getTranslation(key, fallback); + } +} diff --git a/src/main/java/com/minersstudios/mscore/locale/TranslationRegistry.java b/src/main/java/com/minersstudios/mscore/locale/TranslationRegistry.java new file mode 100644 index 00000000..5cdf0f39 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/locale/TranslationRegistry.java @@ -0,0 +1,520 @@ +package com.minersstudios.mscore.locale; + +import net.kyori.adventure.key.Key; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TranslatableComponent; +import net.kyori.adventure.text.renderer.TranslatableComponentRenderer; +import net.kyori.adventure.translation.GlobalTranslator; +import net.kyori.adventure.translation.Translator; +import net.kyori.adventure.util.TriState; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnmodifiableView; + +import java.text.MessageFormat; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import static com.minersstudios.mscore.locale.TranslationRegistryImpl.SINGLETON; + +public interface TranslationRegistry extends Translator { + + /** + * Returns the namespaced key of this registry + * + * @return The namespaced key of this registry + */ + @Override + @NotNull Key name(); + + /** + * Returns the default locale of this registry + * + * @return The default locale of this registry + */ + @NotNull Locale getDefaultLocale(); + + /** + * Returns an unmodifiable view of the translation map + * + * @return An unmodifiable view of the translation map + */ + @NotNull @UnmodifiableView Map getTranslationMap(); + + /** + * Returns the renderer of this registry + * + * @return The renderer of this registry + */ + @NotNull TranslatableComponentRenderer getRenderer(); + + /** + * Gets the translation for the given key + * + * @param key The key of the translation + * @return The translation for the given key, or {@code null} if not found + */ + @Nullable Translation getTranslation(final @NotNull String key); + + /** + * Gets the translation object for the given key + * + * @param key The key of the translation + * @param fallback The fallback of the translation + * @return The translation for the given key, or a new translation with the + * given fallback if not found + */ + @NotNull Translation getTranslation( + final @NotNull String key, + final @Nullable String fallback + ); + + /** + * Gets the translation for the given key, or key if not found + * + * @param key The key of the translation + * @param locale The locale of the translation + * @return The translation for the given key and locale, or key if not found + * @see #translate(String, String, Locale) + */ + @Override + @NotNull MessageFormat translate( + final @NotNull String key, + final @NotNull Locale locale + ); + + /** + * Gets the translation for the given key, or fallback if not found + * + * @param key The key of the translation + * @param fallback The fallback of the translation + * @param locale The locale of the translation + * @return The translation for the given key and locale, or fallback if not + * found + * @see Translation#translate(Locale, String) + */ + @NotNull MessageFormat translate( + final @NotNull String key, + final @Nullable String fallback, + final @NotNull Locale locale + ); + + /** + * Returns a component representing the given translatable component with + * the given locale + * + * @param component The component to render + * @param locale The locale to render the component in + * @return A component representing the given translatable component with + * the given locale + * @deprecated Use {@link #render(Component, Locale)} instead + */ + @Deprecated + @Override + @NotNull Component translate( + final @NotNull TranslatableComponent component, + final @NotNull Locale locale + ); + + /** + * Returns a rendered component representing the given component with the + * given locale + * + * @param component The component to render + * @param locale The locale to render the component in + * @return A rendered component + */ + @NotNull Component render( + final @NotNull Component component, + final @NotNull Locale locale + ); + + /** + * Returns whether this registry has any translations + * + * @return Whether this registry has any translations + */ + @Override + @NotNull TriState hasAnyTranslations(); + + /** + * Checks whether this registry contains the given key + * + * @param key The key to check for + * @return Whether this registry contains the given key + */ + boolean contains(final @Nullable String key); + + /** + * Registers a new translation for the given key + * + * @param key The key to register + * @return The registered translation + * @see #registerKey(String, String) + */ + @NotNull Translation registerKey(final @NotNull String key); + + /** + * Registers a new translation for the given key + * + * @param key The key to register + * @param fallback The fallback to register + * @return The registered translation + */ + @NotNull Translation registerKey( + final @NotNull String key, + final @Nullable String fallback + ); + + /** + * Registers the given translation + * + * @param translation The translation to register + */ + void register(final @NotNull Translation translation); + + /** + * Registers the given translation for the given key and locale + * + * @param key The key to register + * @param locale The locale to register the translation for + * @param translation The translation to register + * @return The registered translation + */ + @NotNull Translation register( + final @NotNull String key, + final @NotNull Locale locale, + final @NotNull String translation + ); + + /** + * Registers the given translations for the given keys + * + * @param keys The keys to register + * @return The registered translations + * @see #registerAllKeys(Iterable) + */ + @NotNull List registerAllKeys(final String @NotNull ... keys); + + /** + * Registers a new translations for the given keys + * + * @param keys The keys to register + * @return The registered translations + * @see #registerKey(String) + */ + @NotNull List registerAllKeys(final @NotNull Iterable keys); + + /** + * Registers a new translations for the given keys and their fallbacks + * + * @param keys The key map containing the keys and their fallbacks + * @return The registered translations + * @see #registerKey(String, String) + */ + @NotNull List registerAllKeys(final @NotNull Map keys); + + /** + * Registers the translations from the given language file + * + * @param languageFile The language file to register the translations from + * @return The registered translations + * @see #registerAll(Locale, Map) + */ + @NotNull List registerAll(final @NotNull LanguageFile languageFile); + + /** + * Registers the given translations for the given locale + * + * @param locale The locale to register the translations for + * @param translationMap The translations to register + * @return The registered translations + * @see #register(String, Locale, String) + */ + @NotNull List registerAll( + final @NotNull Locale locale, + final @NotNull Map translationMap + ); + + /** + * Unregisters the translation for the given key + * + * @param key The key to unregister + * @return Whether the translation was unregistered + */ + boolean unregister(final @NotNull String key); + + /** + * Unregisters the locale for every translation + * + * @param locale The locale to unregister + * @return Whether the locale was unregistered + */ + boolean unregister(final @NotNull Locale locale); + + /** + * Unregisters the locale for the given key + * + * @param key The key to unregister + * @param locale The locale to unregister + * @return Whether the locale was unregistered + */ + boolean unregister( + final @NotNull String key, + final @NotNull Locale locale + ); + + /** + * Unregisters the translations, which were registered by the given language + * file + * + * @param languageFile The language file, which translations should be + * unregistered + * @return Whether any of the translation was unregistered + * @see #unregister(Iterable) + */ + boolean unregister(final @NotNull LanguageFile languageFile); + + /** + * Unregisters all translations for the given keys + * + * @param keys The keys to unregister + * @return Whether any of the translation was unregistered + */ + boolean unregister(final @NotNull Iterable keys); + + /** + * Unregisters all translations + */ + void unregisterAll(); + + /** + * Returns the translation registry singleton + * + * @return The translation registry singleton + */ + static @NotNull TranslationRegistry registry() { + return SINGLETON; + } + + /** + * Registers this registry to the global translator + */ + static void registerGlobal() { + GlobalTranslator.translator().addSource(registry()); + } + + /** + * Unregisters this registry from the global translator + */ + static void unregisterGlobal() { + GlobalTranslator.translator().removeSource(registry()); + } + + static @NotNull Component renderAsComponent( + final @NotNull String key, + final Object @NotNull ... args + ) { + return renderAsComponent(key, registry().getDefaultLocale(), args); + } + + static @NotNull Component renderAsComponent( + final @NotNull String key, + final @Nullable String fallback, + final Object @NotNull ... args + ) { + return renderAsComponent(key, registry().getDefaultLocale(), fallback, args); + } + + @Contract("_, _, _ -> new") + static @NotNull Component renderAsComponent( + final @NotNull String key, + final @NotNull Locale locale, + final Object @NotNull ... args + ) { + return renderAsComponent(key, null, locale, args); + } + + @Contract("_, _, _, _ -> new") + static @NotNull Component renderAsComponent( + final @NotNull String key, + final @Nullable String fallback, + final @NotNull Locale locale, + final Object @NotNull ... args + ) { + return Component.text(renderAsString(key, fallback, locale, args)); + } + + /** + * Gets the translation for the given key and returns it as a string, or if + * it doesn't exist, returns the key + * + * @param key The key of the translation + * @param args The arguments to format the translation with + * @return A string representing the translation for the given key and the + * default locale + * @see #renderAsString(String, Locale, Object...) + */ + static @NotNull String renderAsString( + final @NotNull String key, + final Object @NotNull ... args + ) { + return renderAsString(key, registry().getDefaultLocale(), args); + } + + /** + * Gets the translation for the given key and returns it as a string, or if + * it doesn't exist, returns the fallback + * + * @param key The key of the translation + * @param fallback The fallback of the translation + * @param args The arguments to format the translation with + * @return A string representing the translation for the given key and the + * default locale + * @see #renderAsString(String, String, Locale, Object...) + */ + static @NotNull String renderAsString( + final @NotNull String key, + final @Nullable String fallback, + final Object @NotNull ... args + ) { + return renderAsString(key, registry().getDefaultLocale(), fallback, args); + } + + /** + * Gets the translation for the given key and locale and returns it as a + * string, or if it doesn't exist, returns the key + * + * @param key The key of the translation + * @param locale The locale of the translation + * @return A string representing the translation for the given key and + * locale + * @see #renderAsString(String, String, Locale, Object...) + */ + static @NotNull String renderAsString( + final @NotNull String key, + final @NotNull Locale locale, + final Object @NotNull ... args + ) { + return renderAsString(key, null, locale, args); + } + + /** + * Gets the translation for the given key and locale and returns it as a + * string, or if it doesn't exist, returns the fallback + * + * @param key The key of the translation + * @param fallback The fallback of the translation + * @param locale The locale of the translation + * @param args The arguments to format the translation with + * @return A string representing the translation for the given key and + * locale + * @see #renderAsFormat(String, String, Locale) + */ + static @NotNull String renderAsString( + final @NotNull String key, + final @Nullable String fallback, + final @NotNull Locale locale, + final Object @NotNull ... args + ) { + return renderAsFormat(key, fallback, locale) + .format(args); + } + + /** + * Gets the translation for the given key and returns it as a message + * format, or if it doesn't exist, returns the key + * + * @param key The key of the translation + * @return A message format representing the translation for the given key + * and the default locale + * @see #renderAsFormat(String, Locale) + */ + static @NotNull MessageFormat renderAsFormat(final @NotNull String key) { + return renderAsFormat(key, registry().getDefaultLocale()); + } + + /** + * Gets the translation for the given key and returns it as a message + * format, or if it doesn't exist, returns the fallback + * + * @param key The key of the translation + * @param fallback The fallback of the translation + * @return A message format representing the translation for the given key + * and the default locale + * @see #renderAsFormat(String, String, Locale) + */ + static @NotNull MessageFormat renderAsFormat( + final @NotNull String key, + final @Nullable String fallback + ) { + return renderAsFormat(key, fallback, registry().getDefaultLocale()); + } + + /** + * Gets the translation for the given key and locale and returns it as a + * message format, or if it doesn't exist, returns the key + * + * @param key The key of the translation + * @param locale The locale of the translation + * @return A message format representing the translation for the given key + * and locale + * @see #renderAsFormat(String, String, Locale) + */ + static @NotNull MessageFormat renderAsFormat( + final @NotNull String key, + final @NotNull Locale locale + ) { + return renderAsFormat(key, null, locale); + } + + /** + * Gets the translation for the given key and locale and returns it as a + * message format, or if it doesn't exist, returns the fallback + * + * @param key The key of the translation + * @param fallback The fallback of the translation + * @param locale The locale of the translation + * @return A message format representing the translation for the given key + * and locale + * @see #translate(String, String, Locale) + */ + static @NotNull MessageFormat renderAsFormat( + final @NotNull String key, + final @Nullable String fallback, + final @NotNull Locale locale + ) { + return registry().translate(key, fallback, locale); + } + + /** + * Returns a component representing the given component with the default + * locale + * + * @param component The component to render + * @return A component representing the given component with the default + * locale + * @see #renderComponent(Component, Locale) + */ + static @NotNull Component renderComponent(final @NotNull Component component) { + return renderComponent(component, registry().getDefaultLocale()); + } + + /** + * Returns a component representing the given component with the given + * locale + * + * @param component The component to render + * @param locale The locale to render the component in + * @return A component representing the given component with the given + * locale + */ + static @NotNull Component renderComponent( + final @NotNull Component component, + final @NotNull Locale locale + ) { + return registry().render(component, locale); + } +} diff --git a/src/main/java/com/minersstudios/mscore/locale/TranslationRegistryImpl.java b/src/main/java/com/minersstudios/mscore/locale/TranslationRegistryImpl.java new file mode 100644 index 00000000..5bda6de9 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/locale/TranslationRegistryImpl.java @@ -0,0 +1,312 @@ +package com.minersstudios.mscore.locale; + +import com.minersstudios.mscore.plugin.MSPlugin; +import com.minersstudios.mscore.utility.ChatUtils; +import com.minersstudios.mscore.utility.SharedConstants; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.kyori.adventure.key.Key; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TranslatableComponent; +import net.kyori.adventure.text.renderer.TranslatableComponentRenderer; +import net.kyori.adventure.util.TriState; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnmodifiableView; + +import java.text.MessageFormat; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +final class TranslationRegistryImpl implements TranslationRegistry { + private final Key name; + private final Locale defaultLocale; + private final Map translationMap; + private final TranslatableComponentRenderer renderer; + + static final TranslationRegistryImpl SINGLETON = + new TranslationRegistryImpl( + Key.key(SharedConstants.WHOMINE_NAMESPACE, "translations"), + MSPlugin.globalConfig().getDefaultLocale() + ); + + TranslationRegistryImpl( + final @NotNull Key name, + final @NotNull Locale defaultLocale + ) { + this.name = name; + this.defaultLocale = defaultLocale; + this.translationMap = new ConcurrentHashMap<>(); + this.renderer = new TranslatableComponentRenderer<>() { + + protected @Nullable MessageFormat translate( + final @NotNull String key, + final @NotNull Locale locale + ) { + return this.translate(key, null, locale); + } + + protected @Nullable MessageFormat translate( + final @NotNull String key, + final @Nullable String fallback, + final @NotNull Locale locale + ) { + final Translation translation = TranslationRegistryImpl.this.getTranslation(key); + + return translation == null + ? null + : translation.translateNullable(locale); + } + + protected @NotNull Component renderTranslatable( + final @NotNull TranslatableComponent component, + final @NotNull Locale locale + ) { + return TranslationRegistryImpl.this.translationMap.isEmpty() + ? component + : super.renderTranslatable(component, locale); + } + }; + } + + @Override + public @NotNull Key name() { + return this.name; + } + + @Override + public @NotNull Locale getDefaultLocale() { + return this.defaultLocale; + } + + @Override + public @NotNull @UnmodifiableView Map getTranslationMap() { + return Collections.unmodifiableMap(this.translationMap); + } + + @Override + public @NotNull TranslatableComponentRenderer getRenderer() { + return this.renderer; + } + + public @Nullable Translation getTranslation(final @NotNull String key) { + return this.translationMap.get(key); + } + + public @NotNull Translation getTranslation( + final @NotNull String key, + final @Nullable String fallback + ) { + return this.translationMap.getOrDefault( + key, + new Translation(key, fallback) + ); + } + + @Override + public @NotNull MessageFormat translate( + final @NotNull String key, + final @NotNull Locale locale + ) { + return this.translate(key, null, locale); + } + + @Override + public @NotNull MessageFormat translate( + final @NotNull String key, + final @Nullable String fallback, + final @NotNull Locale locale + ) { + return this + .getTranslation(key, fallback) + .translate(locale, fallback); + } + + @Deprecated + @Override + public @NotNull Component translate( + final @NotNull TranslatableComponent component, + final @NotNull Locale locale + ) { + return this.render(component, locale); + } + + @Override + public @NotNull Component render( + final @NotNull Component component, + final @NotNull Locale locale + ) { + return this.renderer.render(component, locale); + } + + @Override + public @NotNull TriState hasAnyTranslations() { + return TriState.byBoolean(!this.translationMap.isEmpty()); + } + + @Override + public boolean contains(final @Nullable String key) { + return ChatUtils.isNotBlank(key) + && this.translationMap.containsKey(key); + } + + @Override + public @NotNull Translation registerKey(final @NotNull String key) { + return this.registerKey(key, null); + } + + @Override + public @NotNull Translation registerKey( + final @NotNull String key, + final @Nullable String fallback + ) { + return this.translationMap.computeIfAbsent( + key, + k -> new Translation(key, fallback) + ); + } + + @Override + public void register(final @NotNull Translation translation) { + final String key = translation.getKey(); + final Translation existing = this.translationMap.get(key); + + if (existing == null) { + this.translationMap.put(key, translation); + } else { + for (final var entry : translation.entrySet()) { + existing.register( + entry.getKey(), + entry.getValue() + ); + } + } + } + + @Override + public @NotNull Translation register( + final @NotNull String key, + final @NotNull Locale locale, + final @NotNull String translation + ) { + final Translation translationObj = this.registerKey(key, translation); + + translationObj.register( + locale, + new MessageFormat(translation) + ); + + return translationObj; + } + + @Override + public @NotNull List registerAllKeys(final String @NotNull ... keys) { + return this.registerAllKeys( + Arrays.asList(keys) + ); + } + + @Override + public @NotNull List registerAllKeys(final @NotNull Iterable keys) { + final var translations = new ObjectArrayList(); + + for (final var key : keys) { + translations.add( + this.registerKey(key) + ); + } + + return translations; + } + + @Override + public @NotNull List registerAllKeys(final @NotNull Map keys) { + final var translations = new ObjectArrayList(keys.size()); + + for (final var entry : keys.entrySet()) { + translations.add( + this.registerKey( + entry.getKey(), + entry.getValue() + ) + ); + } + + return translations; + } + + @Override + public @NotNull List registerAll(final @NotNull LanguageFile languageFile) { + return this.registerAll( + languageFile.getLocale(), + languageFile.getTranslationMap() + ); + } + + @Override + public @NotNull List registerAll( + final @NotNull Locale locale, + final @NotNull Map translationMap + ) { + final var translations = new ObjectArrayList(translationMap.size()); + + for (final var entry : translationMap.entrySet()) { + translations.add( + this.register( + entry.getKey(), + locale, + entry.getValue() + ) + ); + } + + return translations; + } + + @Override + public boolean unregister(final @NotNull String key) { + return this.translationMap.remove(key) != null; + } + + @Override + public boolean unregister(final @NotNull Locale locale) { + boolean removed = false; + + for (final var translation : this.translationMap.values()) { + removed |= translation.unregister(locale); + } + + return removed; + } + + @Override + public boolean unregister( + final @NotNull String key, + final @NotNull Locale locale + ) { + final Translation translation = this.translationMap.get(key); + + return translation != null + && translation.unregister(locale); + } + + @Override + public boolean unregister(final @NotNull LanguageFile languageFile) { + return this.unregister(languageFile.getTranslationMap().keySet()); + } + + @Override + public boolean unregister(final @NotNull Iterable keys) { + boolean removed = false; + + for (final var key : keys) { + removed |= this.unregister(key); + } + + return removed; + } + + @Override + public void unregisterAll() { + this.translationMap.clear(); + } +} diff --git a/src/main/java/com/minersstudios/mscore/locale/Translations.java b/src/main/java/com/minersstudios/mscore/locale/Translations.java new file mode 100644 index 00000000..dcad2177 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/locale/Translations.java @@ -0,0 +1,386 @@ +package com.minersstudios.mscore.locale; + +import com.minersstudios.mscore.utility.SharedConstants; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import static com.minersstudios.mscore.locale.TranslationRegistry.registry; +import static com.minersstudios.mscore.utility.Font.Chars.*; + +/** + * This class stores all translations used in the WhoMine plugins + * + * @see Translation + * @see Default translation repository + */ +public final class Translations { + // + public static final Translation FORMAT_LEAVE_MESSAGE = register("ms.format.leave.message", "{0}\n\n<---====+====--->\n\n{1}\n\n<---====+====--->"); + public static final Translation LINK_HOVER = register("ms.link.hover", "Click to follow the link"); + public static final Translation COMMAND_HOVER_SUGGEST = register("ms.command.hover.suggest", "Click to enter a command"); + public static final Translation COMMAND_HOVER_RUN = register("ms.command.hover.run", "Click to run the command"); + public static final Translation ON_DISABLE_MESSAGE_TITLE = register("ms.on_disable.message.title", "Server is shutting down"); + public static final Translation ON_DISABLE_MESSAGE_SUBTITLE = register("ms.on_disable.message.subtitle", "Please come back later"); + public static final Translation SERVER_NOT_FULLY_LOADED_TITLE = register("ms.server_not_fully_loaded.title", "You've been kicked from the server"); + public static final Translation SERVER_NOT_FULLY_LOADED_SUBTITLE = register("ms.server_not_fully_loaded.subtitle", "The server hasn't started yet"); + public static final Translation SOMETHING_WENT_WRONG_TITLE = register("ms.something_went_wrong.title", "You've been kicked from the server"); + public static final Translation SOMETHING_WENT_WRONG_SUBTITLE = register("ms.something_went_wrong.subtitle", "Something seems to have gone wrong\nPlease contact the administration\n\nhttps://discord.whomine.net"); + public static final Translation INFO_PLAYER_FILE_CREATED = register("ms.info.player_file_created", "Created a player data file : \"{1}\" for \"{0}\""); + public static final Translation INFO_PLAYER_ITEM_REMOVED = register("ms.info.player_item_removed", "Player : \"{0}\" has had the item : \n\"{1}\" removed"); + public static final Translation INFO_PLAYER_ADDED_IP = register("ms.info.player_added_ip", "A new IP address has been added for player : \"{0}\" ({1}): \"{2}\""); + public static final Translation INFO_PLAYER_DEATH_INFO = register("ms.info.player_death_info", "The world and the coordinates of the player's death : \"{0}\" ({1}) :\n - World : \"{2}\"\n - Coordinates : \"{3}\""); + public static final Translation WARNING_YOU_CANT_DO_THIS_NOW = register("ms.warning.you_cant_do_this_now", "You can't do this now!"); + public static final Translation ERROR_PLAYER_NOT_ONLINE = register("ms.error.player_not_online", "This player is not online"); + public static final Translation ERROR_ID_NOT_FOUND = register("ms.error.id_not_found", "You entered the wrong id, the player linked to it does not exist"); + public static final Translation ERROR_PLAYER_NOT_FOUND = register("ms.error.player_not_found", "This player doesn't exist"); + public static final Translation ERROR_SOMETHING_WENT_WRONG = register("ms.error.something_went_wrong", "Something went wrong..."); + public static final Translation ERROR_WRONG_FORMAT = register("ms.error.wrong_format", "The entered indicator has an incorrect format!"); + public static final Translation ERROR_ONLY_PLAYER_COMMAND = register("ms.error.only_player_command", "This command can only be executed by a player!"); + public static final Translation ERROR_UNKNOWN_COMMAND = register("ms.error.unknown_command", "Unknown command!"); + public static final Translation ERROR_NO_PERMISSION = register("ms.error.no_permission", "Sorry, but you don't have permission to run this command"); + public static final Translation ERROR_FLYING_PLAYER = register("ms.error.flying_player", "Flight isn't enabled on this server"); + public static final Translation ERROR_FLYING_VEHICLE = register("ms.error.flying_vehicle", "Vehicle flight isn't enabled on this server"); + public static final Translation ERROR_CONNECTION_THROTTLE = register("ms.error.connection_throttle", "The connection is in a bad state! Wait before reconnecting"); + public static final Translation ERROR_TOO_MANY_PACKETS = register("ms.error.too_many_packets", "Too many packets sent"); + public static final Translation RESOURCE_PACK_ACCEPTED = register("ms.resource_pack.accepted", "Player : \"{0}\" accepted the resource pack"); + public static final Translation RESOURCE_PACK_DECLINED_CONSOLE = register("ms.resource_pack.declined.console", "Player : \"{0}\" declined the resource pack"); + public static final Translation RESOURCE_PACK_DECLINED_RECEIVER_TITLE = register("ms.resource_pack.declined.receiver.title", "It looks like you didn't accept the resource pack"); + public static final Translation RESOURCE_PACK_DECLINED_RECEIVER_SUBTITLE = register("ms.resource_pack.declined.receiver.subtitle", "In the server settings, change the parameter :\n\n\"Server Resource Packs\" to \"Enabled\""); + public static final Translation RESOURCE_PACK_SUCCESSFULLY_LOADED = register("ms.resource_pack.successfully_loaded", "Player : \"{0}\" successfully loaded the resource pack"); + public static final Translation RESOURCE_PACK_FAILED_DOWNLOAD_CONSOLE = register("ms.resource_pack.failed_download.console", "Player : \"{0}\" failed to download the resource pack"); + public static final Translation RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_TITLE = register("ms.resource_pack.failed_download.receiver.title", "Something seems to have gone wrong"); + public static final Translation RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_SUBTITLE = register("ms.resource_pack.failed_download.receiver.subtitle", "Please contact the administration\nIn the meantime, your resource pack type has been changed to :\n\"No texture pack\""); + public static final Translation BOOK_ANONYMOUS = register("ms.book.anonymous", "Anonymous"); + public static final Translation PRE_LOGIN_BANNED_TITLE = register("ms.pre_login.banned.title", "You've been banned"); + public static final Translation PRE_LOGIN_BANNED_SUBTITLE = register("ms.pre_login.banned.subtitle", "Reason : \"{0}\"\nTime to : \"{1}\""); + public static final Translation PRE_LOGIN_WHITELISTED_TITLE = register("ms.pre_login.whitelisted.title", "You're not whitelisted!"); + public static final Translation PRE_LOGIN_WHITELISTED_SUBTITLE = register("ms.pre_login.whitelisted.subtitle", "Looks like you're still unknown to us\nPlease contact the administration\n\nhttps://discord.whomine.net"); + public static final Translation PRE_LOGIN_TECH_WORKS_TITLE = register("ms.pre_login.tech_works.title", "You've been kicked from the server"); + public static final Translation PRE_LOGIN_TECH_WORKS_SUBTITLE = register("ms.pre_login.tech_works.subtitle", "Tech-work is underway\nSoon you will be able to log on to\n\nhttps://discord.whomine.net"); + public static final Translation COMMAND_BAN_DEFAULT_REASON = register("ms.command.ban.default_reason", "Unknown"); + public static final Translation COMMAND_BAN_ALREADY_SENDER = register("ms.command.ban.already.sender", "Player : \"{0}\" ({1}) is already banned"); + public static final Translation COMMAND_BAN_MESSAGE_RECEIVER_TITLE = register("ms.command.ban.message.receiver.title", "You've been banned"); + public static final Translation COMMAND_BAN_MESSAGE_RECEIVER_SUBTITLE = register("ms.command.ban.message.receiver.subtitle", "Reason : \"{0}\"\nTime to : \"{1}\""); + public static final Translation COMMAND_BAN_MESSAGE_SENDER = register("ms.command.ban.message.sender", "Player : \"{0}\" ({1}) has been banned :\n - Reason : \"{2}\"\n - Time to : \"{3}\""); + public static final Translation COMMAND_BAN_TIME_FOREVER = register("ms.command.ban.time.forever", "Forever"); + public static final Translation COMMAND_UNBAN_NOT_BANNED = register("ms.command.unban.not_banned", "Player : \"{0}\" ({1}) is not banned"); + public static final Translation COMMAND_UNBAN_MESSAGE_SENDER = register("ms.command.unban.message.sender", "Player : \"{0}\" ({1}) has been unbanned"); + public static final Translation COMMAND_MUTE_DEFAULT_REASON = register("ms.command.mute.default_reason", "Unknown"); + public static final Translation COMMAND_MUTE_ALREADY_RECEIVER = register("ms.command.mute.already.receiver", "You are muted"); + public static final Translation COMMAND_MUTE_ALREADY_SENDER = register("ms.command.mute.already.sender", "Player : \"{0}\" ({1}) is already muted"); + public static final Translation COMMAND_MUTE_MESSAGE_RECEIVER = register("ms.command.mute.message.receiver", "You've been muted :\n - Reason : \"{0}\"\n - Time to : \"{1}\""); + public static final Translation COMMAND_MUTE_MESSAGE_SENDER = register("ms.command.mute.message.sender", "Player : \"{0}\" ({1}) has been muted :\n - Reason : \"{2}\"\n - Time to : \"{3}\""); + public static final Translation COMMAND_UNMUTE_NOT_MUTED = register("ms.command.unmute.not_muted", "Player : \"{0}\" ({1}) is not muted"); + public static final Translation COMMAND_UNMUTE_SENDER_MESSAGE = register("ms.command.unmute.sender.message", "Player : \"{0}\" ({1}) has been unmuted"); + public static final Translation COMMAND_UNMUTE_RECEIVER_MESSAGE = register("ms.command.unmute.receiver.message", "You've been unmuted"); + public static final Translation COMMAND_KICK_DEFAULT_REASON = register("ms.command.kick.default_reason", "Unknown"); + public static final Translation COMMAND_KICK_MESSAGE_RECEIVER_TITLE = register("ms.command.kick.message.receiver.title", "You've been kicked"); + public static final Translation COMMAND_KICK_MESSAGE_RECEIVER_SUBTITLE = register("ms.command.kick.message.receiver.subtitle", "Reason :\n\"{0}\""); + public static final Translation COMMAND_KICK_MESSAGE_SENDER = register("ms.command.kick.message.sender", "Player : \"{0}\" ({1}) has been kicked :\n - Reason : \"{2}\""); + public static final Translation COMMAND_WHITE_LIST_RELOAD = register("ms.command.white_list.reload", "White List has been reloaded"); + public static final Translation COMMAND_WHITE_LIST_ADD_NICKNAME_WARNING = register("ms.command.white_list.add.nickname_warning", "Use nickname to add a player!"); + public static final Translation COMMAND_WHITE_LIST_ADD_ALREADY = register("ms.command.white_list.add.already", "Player : \"{0}\" ({1}) is already in the white list"); + public static final Translation COMMAND_WHITE_LIST_ADD_SENDER_MESSAGE = register("ms.command.white_list.add.sender.message", "Player : \"{0}\" ({1}) has been added to the white list"); + public static final Translation COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_TITLE = register("ms.command.white_list.remove.receiver.message.title", "You've been kicked from the server"); + public static final Translation COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_SUBTITLE = register("ms.command.white_list.remove.receiver.message.subtitle", "You've been removed from the white list"); + public static final Translation COMMAND_WHITE_LIST_REMOVE_SENDER_MESSAGE = register("ms.command.white_list.remove.sender.message", "Player : \"{0}\" ({1}) has been removed from the white list"); + public static final Translation COMMAND_WHITE_LIST_REMOVE_NOT_FOUND = register("ms.command.white_list.remove.not_found", "Player : \"{0}\" ({1}) is not in the white list"); + public static final Translation COMMAND_SIT_IN_AIR = register("ms.command.sit.in_air", "You can't sit in the air!"); + public static final Translation COMMAND_TRY_VARIANT_SUCCESS = register("ms.command.try.variant.success", "Success"); + public static final Translation COMMAND_TRY_VARIANT_FAIL = register("ms.command.try.variant.fail", "Fail"); + public static final Translation COMMAND_TELEPORT_TO_LAST_DEATH_NO_POSITION = register("ms.command.teleport_to_last_death.no_position", "Player : \"{0}\" ({1}) has no death position!"); + public static final Translation COMMAND_TELEPORT_TO_LAST_DEATH_SENDER_MESSAGE = register("ms.command.teleport_to_last_death.sender.message", "Player : \"{0}\" ({1}) has been teleported to the last death position"); + public static final Translation COMMAND_WORLD_TELEPORT_WORLD_NOT_FOUND = register("ms.command.world_teleport.world_not_found", "This world doesn't exist!"); + public static final Translation COMMAND_WORLD_TELEPORT_TOO_BIG_COORDINATES = register("ms.command.world_teleport.too_big_coordinates", "The coordinates are too big!"); + public static final Translation COMMAND_WORLD_TELEPORT_SENDER_MESSAGE = register("ms.command.world_teleport.sender.message", "Player : \"{0}\" ({1}) has been teleported :\n - World : \"{2}\"\n - X : \"{3}\"\n - Y : \"{4}\"\n - Z : \"{5}\""); + public static final Translation COMMAND_GET_MAP_LOCATION_NO_MAP_IN_RIGHT_HAND = register("ms.command.get_map_location.no_map_in_right_hand", "You don't have a map in your right hand!"); + public static final Translation COMMAND_GET_MAP_LOCATION_FORMAT = register("ms.command.get_map_location.format", "World of the map : \"{0}\"\n - X : \"{1}\"\n - Y : \"{2}\"\n - Z : \"{3}\""); + public static final Translation COMMAND_GET_MAP_LOCATION_COMMAND_BUTTON_TEXT = register("ms.command.get_map_location.command_button_text", "\n Click to teleport\n"); + public static final Translation COMMAND_MSESSENTIALS_RELOAD_SUCCESS = register("ms.command.msessentials.reload.success", "The plugin has been reloaded in {0} ms"); + public static final Translation COMMAND_MSESSENTIALS_UPDATE_IDS_SUCCESS = register("ms.command.msessentials.update_ids.success", "The ID list has been successfully reloaded in {0} ms"); + public static final Translation COMMAND_MSESSENTIALS_UPDATE_MUTES_SUCCESS = register("ms.command.msessentials.update_mutes.success", "The mute list has been successfully reloaded in {0} ms"); + public static final Translation COMMAND_MSCORE_RELOAD_CONFIG_SUCCESS = register("ms.command.mscore.reload_config.success", "The configuration has been successfully reloaded in {0} ms"); + public static final Translation COMMAND_PLAYER_UPDATE_SUCCESS = register("ms.command.player.update.success", "Data for player : \"{0}\" ({1}) has been successfully updated"); + public static final Translation COMMAND_PLAYER_FIRST_JOIN = register("ms.command.player.first_join", "Player : \"{0}\" ({1}) has joined the server for the first time"); + public static final Translation COMMAND_PLAYER_NAME_ABOUT = register("ms.command.player.name.about", "Player's name information :\n - Full name : \"{0}\"\n - Nickname : \"{1}\"\n - UUID : \"{2}\""); + public static final Translation COMMAND_PLAYER_NAME_FULL_RESET_SENDER = register("ms.command.player.name.full_reset.sender", "Player : \"{0}\" ({1}) has had their full name reset"); + public static final Translation COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_TITLE = register("ms.command.player.name.full_reset.receiver.title", "You've been kicked from the server"); + public static final Translation COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_SUBTITLE = register("ms.command.player.name.full_reset.receiver.subtitle", "Your full name has been reset"); + public static final Translation COMMAND_PLAYER_NAME_GET_FIRST_NAME = register("ms.command.player.name.get.first_name", "First name : \"{0}\""); + public static final Translation COMMAND_PLAYER_NAME_GET_LAST_NAME = register("ms.command.player.name.get.last_name", "Last name : \"{0}\""); + public static final Translation COMMAND_PLAYER_NAME_GET_PATRONYMIC = register("ms.command.player.name.get.patronymic", "Patronymic : \"{0}\""); + public static final Translation COMMAND_PLAYER_NAME_NOW_FULL = register("ms.command.player.name.now_full", "Now full name of the player looks like this :\n "); + public static final Translation COMMAND_PLAYER_PRONOUNS_GET = register("ms.command.player.pronouns.get", "The pronouns of the player : \"{0}\" ({1})\n Equal to : \"{2}\""); + public static final Translation COMMAND_PLAYER_PRONOUNS_SET = register("ms.command.player.pronouns.set", "The pronouns of the player : \"{0}\" ({1})\n Has been set to : \"{2}\""); + public static final Translation COMMAND_PLAYER_PRONOUNS_USE_ONE_OF = register("ms.command.player.pronouns.use_one_of", "Use one of the following variants :\n {0}"); + public static final Translation COMMAND_PLAYER_BAN_INFO_INFO = register("ms.command.player.ban_info.info", "Information about the player's ban of : \"{0}\" ({1})\n - Source : \"{2}\"\n - Reason : \"{3}\"\n - Time from : \"{4}\"\n - Time to : \"{5}\""); + public static final Translation COMMAND_PLAYER_BAN_INFO_INFO_NOT_BANNED = register("ms.command.player.ban_info.info_not_banned", "Information about the player's ban of : \"{0}\" ({1})\n - Not banned"); + public static final Translation COMMAND_PLAYER_BAN_INFO_NOT_BANNED = register("ms.command.player.ban_info.not_banned", "This parameter cannot be changed and/or read because the player : \"{0}\" ({1}) is not banned"); + public static final Translation COMMAND_PLAYER_BAN_INFO_GET_REASON = register("ms.command.player.ban_info.get.reason", "The reason for the player's ban of : \"{0}\" ({1})\n - \"{2}\""); + public static final Translation COMMAND_PLAYER_BAN_INFO_SET_REASON = register("ms.command.player.ban_info.set.reason", "The reason for the player's ban of : \"{0}\" ({1})\n - Has been set to : \"{2}\""); + public static final Translation COMMAND_PLAYER_BAN_INFO_GET_TIME_TO = register("ms.command.player.ban_info.get.time_to", "Deadline for the player's ban of : \"{0}\" ({1})\n - \"{2}\""); + public static final Translation COMMAND_PLAYER_BAN_INFO_SET_TIME_TO = register("ms.command.player.ban_info.set.time_to", "Deadline for the player's ban of : \"{0}\" ({1})\n - Has been set to : \"{2}\""); + public static final Translation COMMAND_PLAYER_MUTE_INFO_INFO = register("ms.command.player.mute_info.info", "Information about the player's mute of : \"{0}\" ({1})\n - Source : \"{2}\"\n - Reason : \"{3}\"\n - Time from : \"{4}\"\n - Time to : \"{5}\""); + public static final Translation COMMAND_PLAYER_MUTE_INFO_INFO_NOT_MUTED = register("ms.command.player.mute_info.info_not_muted", "Information about the player's mute of : \"{0}\" ({1})\n - Not muted"); + public static final Translation COMMAND_PLAYER_MUTE_INFO_NOT_MUTED = register("ms.command.player.mute_info.not_muted", "This parameter cannot be changed and/or read because the player : \"{0}\" ({1}) is not muted"); + public static final Translation COMMAND_PLAYER_MUTE_INFO_GET_REASON = register("ms.command.player.mute_info.get.reason", "The reason for the player's mute of : \"{0}\" ({1})\n - \"{2}\""); + public static final Translation COMMAND_PLAYER_MUTE_INFO_SET_REASON = register("ms.command.player.mute_info.set.reason", "The reason for the player's mute of : \"{0}\" ({1})\n - Has been set to : \"{2}\""); + public static final Translation COMMAND_PLAYER_MUTE_INFO_GET_TIME_TO = register("ms.command.player.mute_info.get.time_to", "Deadline for the player's mute of : \"{0}\" ({1})\n - \"{2}\""); + public static final Translation COMMAND_PLAYER_MUTE_INFO_SET_TIME_TO = register("ms.command.player.mute_info.set.time_to", "Deadline for the player's mute of : \"{0}\" ({1})\n - Has been set to : \"{2}\""); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_USE_ONE_OF = register("ms.command.player.game_params.use_one_of", "Use one of the following parameters :\n game-mode, health, air"); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE = register("ms.command.player.game_params.get.game_mode", "The game mode of the player : \"{0}\" ({1})\n Is :\n - In the file : \"{2}\""); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE_FULL = register("ms.command.player.game_params.get.game_mode_full", "The game mode of the player : \"{0}\" ({1})\n Is :\n - In the file : \"{2}\"\n - In the game : \"{3}\""); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_SET_GAME_MODE = register("ms.command.player.game_params.set.game_mode", "The game mode of the player : \"{0}\" ({1})\n Has been set to : \"{2}\""); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_GAME_MODE_USE_ONE_OF = register("ms.command.player.game_params.game_mode_use_one_of", "Use one of the following game modes :\n survival, creative, adventure, spectator"); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH = register("ms.command.player.game_params.get.health", "The health of the player : \"{0}\" ({1})\n Is :\n - In the file : \"{2}\""); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH_FULL = register("ms.command.player.game_params.get.health_full", "The health of the player : \"{0}\" ({1})\n Is :\n - In the file : \"{2}\"\n - In the game : \"{3}\""); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_SET_HEALTH = register("ms.command.player.game_params.set.health", "The health of the player : \"{0}\" ({1})\n Has been set to : \"{2}\""); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_GET_AIR = register("ms.command.player.game_params.get.air", "The air of the player : \"{0}\" ({1})\n Is :\n - In the file : \"{2}\""); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_GET_AIR_FULL = register("ms.command.player.game_params.get.air_full", "The air of the player : \"{0}\" ({1})\n Is :\n - In the file : \"{2}\"\n - In the game : \"{3}\""); + public static final Translation COMMAND_PLAYER_GAME_PARAMS_SET_AIR = register("ms.command.player.game_params.set.air", "The air of the player : \"{0}\" ({1})\n Has been set to : \"{2}\""); + public static final Translation COMMAND_PLAYER_SETTINGS_USE_ONE_OF = register("ms.command.player.settings.use_one_of", "Use one of the following parameters :\n resourcepack, skin"); + public static final Translation COMMAND_PLAYER_SETTINGS_GET_RESOURCEPACK_TYPE = register("ms.command.player.settings.get.resourcepack_type", "The resource pack type of the player : \"{0}\" ({1})\n Is : \"{2}\""); + public static final Translation COMMAND_PLAYER_SETTINGS_SET_RESOURCEPACK_TYPE = register("ms.command.player.settings.set.resourcepack_type", "The resource pack type of the player : \"{0}\" ({1})\n Has been set to : \"{2}\""); + public static final Translation COMMAND_PLAYER_SETTINGS_RESOURCEPACK_TYPE_USE_ONE_OF = register("ms.command.player.settings.resourcepack_type_use_one_of", "Use one of the following resource pack types :\n {0}"); + public static final Translation COMMAND_PLAYER_SETTINGS_GET_SKIN = register("ms.command.player.settings.get.skin", "The skin of the player : \"{0}\" ({1})\n Is : \"{2}\""); + public static final Translation COMMAND_PLAYER_SETTINGS_GET_NO_SKIN = register("ms.command.player.settings.get.no_skin", "The skin of the player : \"{0}\" ({1})\n Is not set"); + public static final Translation COMMAND_PLAYER_SETTINGS_SET_SKIN = register("ms.command.player.settings.set.skin", "The skin of the player : \"{0}\" ({1})\n Has been set to : \"{2}\""); + public static final Translation COMMAND_PLAYER_SETTINGS_ADD_SKIN = register("ms.command.player.settings.add.skin", "You've added a skin : \"{0}\"\n For the player : \"{1}\" ({2})"); + public static final Translation COMMAND_PLAYER_SETTINGS_ADD_SKIN_ERROR = register("ms.command.player.settings.add.skin.error", "Failed to add a skin : \"{0}\"\n For the player : \"{1}\" ({2})"); + public static final Translation COMMAND_PLAYER_SETTINGS_REMOVE_SKIN = register("ms.command.player.settings.remove.skin", "You've removed a skin : \"{0}\"\n For the player : \"{1}\" ({2})"); + public static final Translation COMMAND_PLAYER_SETTINGS_SKIN_NOT_FOUND = register("ms.command.player.settings.skin_not_found", "This player doesn't have a skin named :\n \"{0}\""); + public static final Translation COMMAND_PLAYER_SETTINGS_SKIN_USE_ONE_OF = register("ms.command.player.settings.skin.use_one_of", "Use one of the following parameters :\n set, add, remove"); + public static final Translation COMMAND_MSBLOCK_GIVE_WRONG_BLOCK = register("ms.command.msblock.give.wrong_block", "This block doesn't exist"); + public static final Translation COMMAND_MSBLOCK_GIVE_SUCCESS = register("ms.command.msblock.give.success", "Given {0} {1} For the player : {2}"); + public static final Translation COMMAND_MSBLOCK_RELOAD_SUCCESS = register("ms.command.msblock.reload.success", "The plugin has been reloaded in {0} ms"); + public static final Translation COMMAND_MSDECOR_GIVE_WRONG_DECOR = register("ms.command.msdecor.give.wrong_decor", "This decor doesn't exist"); + public static final Translation COMMAND_MSDECOR_GIVE_SUCCESS = register("ms.command.msdecor.give.success", "Given {0} {1} For the player : {2}"); + public static final Translation COMMAND_MSITEM_GIVE_WRONG_ITEM = register("ms.command.msitem.give.wrong_item", "This item doesn't exist"); + public static final Translation COMMAND_MSITEM_GIVE_SUCCESS = register("ms.command.msitem.give.success", "Given {0} {1} For the player : {2}"); + public static final Translation COMMAND_MSITEM_RELOAD_SUCCESS = register("ms.command.msitem.reload.success", "The plugin has been reloaded in {0} ms"); + public static final Translation COMMAND_DISCORD = register("ms.command.discord", "Check out our Discord server :\n - {0}\n If you want to link the account, use :\n - {1}"); + public static final Translation COMMAND_DISCORD_LINK_SUCCESS = register("ms.command.discord.link.success", "Your account has been successfully linked to : {0}"); + public static final Translation COMMAND_DISCORD_UNLINK_NO_LINKS = register("ms.command.discord.unlink.no_links", "You don't have any linked accounts"); + public static final Translation COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS = register("ms.command.discord.unlink.minecraft.success", "Your account has been successfully unlinked from : {0}"); + public static final Translation COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS = register("ms.command.discord.unlink.discord.success", "```Your account has been successfully unlinked from :\n{0} ({1})```"); + public static final Translation COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND = register("ms.command.set_server_spawn.world_not_found", "This world doesn't exist!"); + public static final Translation COMMAND_SET_SERVER_SPAWN_TOO_BIG_COORDINATES = register("ms.command.set_server_spawn.too_big_coordinates", "The coordinates are too big!"); + public static final Translation COMMAND_SET_SERVER_SPAWN_SUCCESSFULLY_SET = register("ms.command.set_server_spawn.successfully_set", "The spawn of the server has been successfully set to :\n - World : \"{0}\"\n - X : \"{1}\"\n - Y : \"{2}\"\n - Z : \"{3}\"\n - Yaw : \"{4}\"\n - Pitch : \"{5}\""); + public static final Translation DISCORD_SERVER_ENABLED = register("ms.discord.server.enabled", ":white_check_mark: **Interspace Hole Opened**"); + public static final Translation DISCORD_SERVER_DISABLED = register("ms.discord.server.disabled", ":octagonal_sign: **Interspace Hole Closed**"); + public static final Translation DISCORD_BOT_STATUS = register("ms.discord.bot.status", "WhoMine | {0}"); + public static final Translation DISCORD_NOT_A_USER = register("ms.discord.not_a_user", ":exclamation: You must have the **«Participant»** role on the server :\nhttps://discord.whomine.net"); + public static final Translation DISCORD_NO_CODE = register("ms.discord.no_code", ":exclamation: Code not found"); + public static final Translation DISCORD_INVALID_CODE = register("ms.discord.invalid_code", ":exclamation: The code must be 4 digits long!"); + public static final Translation DISCORD_CODE_ATTEMPTS_LIMIT_REACHED = register("ms.discord.code_attempts_limit_reached", ":exclamation: The maximum number of attempts has been exceeded\nWait 5 minutes before you get this opportunity"); + public static final Translation DISCORD_MESSAGE_ATTEMPTS_LIMIT_REACHED = register("ms.discord.message_attempts_limit_reached", ":exclamation: Slow down, not so fast!"); + public static final Translation DISCORD_UNKNOWN_COMMAND = register("ms.discord.unknown_command", ":exclamation: Unknown action!"); + public static final Translation DISCORD_NOT_LINKED = register("ms.discord.not_linked", ":exclamation: You haven't linked your account!\nUse the **/discord link** on the server"); + public static final Translation DISCORD_ALREADY_LINKED = register("ms.discord.already_linked", "```You have already linked your account to this user!```"); + public static final Translation DISCORD_SUCCESSFULLY_LINKED = register("ms.discord.successfully_linked", "```You have successfully linked your account to :\n{0} ({1})```"); + public static final Translation DISCORD_BANNED = register("ms.discord.banned", "```Your account : {0} ({1})\nHas been banned :\n - Reason : {2}\n - Time to : {3}```"); + public static final Translation DISCORD_UNBANNED = register("ms.discord.unbanned", "```Your account : {0} ({1})\nHas been unbanned```"); + public static final Translation DISCORD_MUTED = register("ms.discord.muted", "```Your account : {0} ({1})\nHas been muted :\n - Reason : {2}\n - Time to : {3}```"); + public static final Translation DISCORD_UNMUTED = register("ms.discord.unmuted", "```Your account : {0} ({1})\nHas been unmuted```"); + public static final Translation DISCORD_EMBED_TITLE = register("ms.discord.embed.title", "#WhoMine - TARDIS"); + public static final Translation DISCORD_SKIN_SERVICE_UNAVAILABLE = register("ms.discord.skin.service_unavailable", ":exclamation: Skin service is currently unavailable!\nContact the administration for help"); + public static final Translation DISCORD_SKIN_ONLY_ONE_IMG = register("ms.discord.skin.only_one_img", ":exclamation: If you want to import a skin, send only 1 image"); + public static final Translation DISCORD_SKIN_INVALID_IMG = register("ms.discord.skin.invalid_img", ":exclamation: This image does not look like a skin! \n- The image size must be **64 x 64**\n- The image must be in **.png** format"); + public static final Translation DISCORD_SKIN_TOO_MANY_SKINS = register("ms.discord.skin.too_many_skins", "```Your account :\n{0} ({1})\n\nAlready has the maximum number of skins available, delete one of them to add a new one\n\nIf you want to see a list of your skins, write \"Yes,\" otherwise write \"No\"```"); + public static final Translation DISCORD_SKIN_ALREADY_SET = register("ms.discord.skin.already_set", "```Your account :\n{0} ({1})\n\nAlready has a skin set with this nam\n\nIf you want to replace it, write \"Yes,\" otherwise write \"No\"```"); + public static final Translation DISCORD_SKIN_VARIANT_YES = register("ms.discord.skin.variant.yes", "Yes"); + public static final Translation DISCORD_SKIN_VARIANT_NO = register("ms.discord.skin.variant.no", "No"); + public static final Translation DISCORD_SKIN_VARIANT_NO_REPLY = register("ms.discord.skin.variant.no.reply", "Action canceled"); + public static final Translation DISCORD_SKIN_INVALID_NAME_REGEX = register("ms.discord.skin.invalid_name_regex", ":exclamation: Incorrect name format!"); + public static final Translation DISCORD_SKIN_NO_NAME = register("ms.discord.skin.no_name", "Send the skin, with the suggested name written in the message"); + public static final Translation DISCORD_SKIN_LIST_OF_SKINS = register("ms.discord.skin.list_of_skins", "```Here is the list of your skins, write the number of the necessary one to see the list of actions with the skin : {0}```"); + public static final Translation DISCORD_SKIN_LIST_OF_SKIN_ACTIONS = register("ms.discord.skin.list_of_skin_actions", "```Here is a list of skin actions, write the number of the action you want to perform or something else to cancel the action :\n1: Edit an image\n2: Rename the skin\n3: Remove the skin```"); + public static final Translation DISCORD_SKIN_ACTION_EDIT_INFO = register("ms.discord.skin.action.edit.info", "```Send a new skin image or something else to cancel the action```"); + public static final Translation DISCORD_SKIN_ACTION_RENAME_INFO = register("ms.discord.skin.action.rename.info", "```Send a new name for the skin```"); + public static final Translation DISCORD_SKIN_INVALID_INDEX = register("ms.discord.skin.invalid_index", "Incorrect index!"); + public static final Translation DISCORD_SKIN_SUCCESSFULLY_ADDED = register("ms.discord.skin.successfully_added", "```You have successfully added a new skin :\n{0}\n\nTo your account : {1} ({2})```"); + public static final Translation DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT = register("ms.discord.skin.successfully_added.minecraft", "You have successfully added a new skin :\n{0}"); + public static final Translation DISCORD_SKIN_EDIT_ALREADY_SET = register("ms.discord.skin.edit.already_set", "```Your account :\n{0} ({1})\n\nAlready has a skin set with this name```"); + public static final Translation DISCORD_SKIN_SUCCESSFULLY_EDITED = register("ms.discord.skin.successfully_edited", "```You have successfully edited the skin :\n{0}\n\nTo your account : {1} ({2})```"); + public static final Translation DISCORD_SKIN_SUCCESSFULLY_EDITED_MINECRAFT = register("ms.discord.skin.successfully_edited.minecraft", "You have successfully edited the skin : {0}"); + public static final Translation DISCORD_SKIN_SUCCESSFULLY_REMOVED = register("ms.discord.skin.successfully_removed", "```You have successfully removed the skin :\n{0}\n\nFrom your account : {1} ({2})```"); + public static final Translation DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT = register("ms.discord.skin.successfully_removed.minecraft", "You have successfully removed the skin : {0}"); + public static final Translation DISCORD_SKIN_SUCCESSFULLY_RENAMED = register("ms.discord.skin.successfully_renamed", "```You have successfully renamed the skin :\n{0}\n\nTo : {1}\n\nIn your account : {2} ({3})```"); + public static final Translation DISCORD_SKIN_SUCCESSFULLY_RENAMED_MINECRAFT = register("ms.discord.skin.successfully_renamed.minecraft", "You have successfully renamed the skin :\n {0}\n To : {1}"); + public static final Translation DISCORD_COMMAND_LIST_OF_SKINS = register("ms.discord.command.list_of_skins", "```Here's a list of your skins : {0}```"); + public static final Translation DISCORD_COMMAND_SKIN_NOT_FOUND = register("ms.discord.command.skin_not_found", "No skin was found on your account as requested : {0}"); + public static final Translation DISCORD_COMMAND_INVALID_ARGUMENTS = register("ms.discord.command.invalid_arguments", "Invalid arguments!"); + public static final Translation MENU_SKINS_TITLE = register("ms.menu.skins.title", PIXEL_SPLIT_M10 + SKINS_MENU_SCREEN); + public static final Translation MENU_SKINS_BUTTON_APPLY = register("ms.menu.skins.button.apply", "Apply skin"); + public static final Translation MENU_SKINS_BUTTON_DELETE = register("ms.menu.skins.button.delete", "Delete skin"); + public static final Translation MENU_DISCORD_TITLE = register("ms.menu.discord.title", PIXEL_SPLIT_M10 + DISCORD_LINK_SCREEN); + public static final Translation MENU_DISCORD_NUMBERS_0 = register("ms.menu.discord.numbers.0", DISCORD_NUMBER_0); + public static final Translation MENU_DISCORD_NUMBERS_1 = register("ms.menu.discord.numbers.1", DISCORD_NUMBER_1); + public static final Translation MENU_DISCORD_NUMBERS_2 = register("ms.menu.discord.numbers.2", DISCORD_NUMBER_2); + public static final Translation MENU_DISCORD_NUMBERS_3 = register("ms.menu.discord.numbers.3", DISCORD_NUMBER_3); + public static final Translation MENU_DISCORD_NUMBERS_4 = register("ms.menu.discord.numbers.4", DISCORD_NUMBER_4); + public static final Translation MENU_DISCORD_NUMBERS_5 = register("ms.menu.discord.numbers.5", DISCORD_NUMBER_5); + public static final Translation MENU_DISCORD_NUMBERS_6 = register("ms.menu.discord.numbers.6", DISCORD_NUMBER_6); + public static final Translation MENU_DISCORD_NUMBERS_7 = register("ms.menu.discord.numbers.7", DISCORD_NUMBER_7); + public static final Translation MENU_DISCORD_NUMBERS_8 = register("ms.menu.discord.numbers.8", DISCORD_NUMBER_8); + public static final Translation MENU_DISCORD_NUMBERS_9 = register("ms.menu.discord.numbers.9", DISCORD_NUMBER_9); + public static final Translation MENU_CRAFTS_CATEGORIES_TITLE = register("ms.menu.crafts.categories.title", PIXEL_SPLIT_M10 + CRAFTS_CATEGORIES_SCREEN); + public static final Translation MENU_CRAFTS_CATEGORY_TITLE = register("ms.menu.crafts.category.title", PIXEL_SPLIT_M10 + CRAFTS_SCREEN); + public static final Translation MENU_CRAFTS_CRAFT_TITLE = register("ms.menu.crafts.craft.title", PIXEL_SPLIT_M10 + CRAFT_SCREEN); + public static final Translation MENU_CRAFTS_BUTTON_PREVIOUS_PAGE = register("ms.menu.crafts.button.previous_page", "Previous page"); + public static final Translation MENU_CRAFTS_BUTTON_NEXT_PAGE = register("ms.menu.crafts.button.next_page", "Next page"); + public static final Translation MENU_PRONOUNS_TITLE = register("ms.menu.pronouns.title", "§8Choose a form of address"); + public static final Translation MENU_PRONOUNS_BUTTON_HE_TITLE = register("ms.menu.pronouns.button.he.title", "He"); + public static final Translation MENU_PRONOUNS_BUTTON_HE_LORE = register("ms.menu.pronouns.button.he.lore", "You'll be addressed as he/him"); + public static final Translation MENU_PRONOUNS_BUTTON_SHE_TITLE = register("ms.menu.pronouns.button.she.title", "She"); + public static final Translation MENU_PRONOUNS_BUTTON_SHE_LORE = register("ms.menu.pronouns.button.she.lore", "You'll be addressed as she/her"); + public static final Translation MENU_PRONOUNS_BUTTON_THEY_TITLE = register("ms.menu.pronouns.button.they.title", "They"); + public static final Translation MENU_PRONOUNS_BUTTON_THEY_LORE = register("ms.menu.pronouns.button.they.lore", "You'll be addressed as they/them"); + public static final Translation MENU_RESOURCE_PACK_TITLE = register("ms.menu.resource_pack.title", "§8Choose a resource pack"); + public static final Translation MENU_RESOURCE_PACK_BUTTON_INFO_TITLE = register("ms.menu.resource_pack.button.info.title", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_INFO_LORE_0 = register("ms.menu.resource_pack.button.info.lore.0", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_INFO_LORE_1 = register("ms.menu.resource_pack.button.info.lore.1", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_INFO_LORE_2 = register("ms.menu.resource_pack.button.info.lore.2", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_INFO_LORE_3 = register("ms.menu.resource_pack.button.info.lore.3", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_INFO_LORE_4 = register("ms.menu.resource_pack.button.info.lore.4", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_NONE_TITLE = register("ms.menu.resource_pack.button.none.title", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_NONE_LORE_0 = register("ms.menu.resource_pack.button.none.lore.0", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_NONE_LORE_1 = register("ms.menu.resource_pack.button.none.lore.1", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_NONE_KICK_TITLE = register("ms.menu.resource_pack.button.none.kick.title", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_NONE_KICK_SUBTITLE = register("ms.menu.resource_pack.button.none.kick.subtitle", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_LITE_TITLE = register("ms.menu.resource_pack.button.lite.title", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_LITE_LORE_0 = register("ms.menu.resource_pack.button.lite.lore.0", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_LITE_LORE_1 = register("ms.menu.resource_pack.button.lite.lore.1", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_LITE_LORE_2 = register("ms.menu.resource_pack.button.lite.lore.2", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_LITE_LORE_3 = register("ms.menu.resource_pack.button.lite.lore.3", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_TITLE = register("ms.menu.resource_pack.button.full.title", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_0 = register("ms.menu.resource_pack.button.full.lore.0", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_1 = register("ms.menu.resource_pack.button.full.lore.1", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_2 = register("ms.menu.resource_pack.button.full.lore.2", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_3 = register("ms.menu.resource_pack.button.full.lore.3", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_4 = register("ms.menu.resource_pack.button.full.lore.4", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_5 = register("ms.menu.resource_pack.button.full.lore.5", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_6 = register("ms.menu.resource_pack.button.full.lore.6", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_7 = register("ms.menu.resource_pack.button.full.lore.7", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_8 = register("ms.menu.resource_pack.button.full.lore.8", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_9 = register("ms.menu.resource_pack.button.full.lore.9", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_10 = register("ms.menu.resource_pack.button.full.lore.10", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_11 = register("ms.menu.resource_pack.button.full.lore.11", null); + public static final Translation MENU_RESOURCE_PACK_BUTTON_FULL_LORE_12 = register("ms.menu.resource_pack.button.full.lore.12", null); + public static final Translation MENU_RENAMES_TITLE = register("ms.menu.renames.title", PIXEL_SPLIT_M10 + RENAMES_SCREEN); + public static final Translation MENU_RENAMES_BUTTON_PREVIOUS_PAGE = register("ms.menu.renames.button.previous_page", "Previous page"); + public static final Translation MENU_RENAMES_BUTTON_NEXT_PAGE = register("ms.menu.renames.button.next_page", "Next page"); + public static final Translation MENU_RENAME_TITLE = register("ms.menu.rename.title", PIXEL_SPLIT_M20 + RENAME_SCREEN); + public static final Translation MENU_RENAME_NO_EXP = register("ms.menu.rename.no_exp", "You are 1 level short of experience"); + public static final Translation REGISTRATION_ANONYMOUS_NAME = register("ms.registration.anonymous.name", "[0] Anonymous"); + public static final Translation REGISTRATION_ONLY_CYRILLIC = register("ms.registration.only_cyrillic", "Use only the Cyrillic alphabet, no spaces!"); + public static final Translation REGISTRATION_SIGN_FIRST_NAME_0 = register("ms.registration.sign.first_name.0", ""); + public static final Translation REGISTRATION_SIGN_FIRST_NAME_1 = register("ms.registration.sign.first_name.1", "---===+===---"); + public static final Translation REGISTRATION_SIGN_FIRST_NAME_2 = register("ms.registration.sign.first_name.2", "Type your"); + public static final Translation REGISTRATION_SIGN_FIRST_NAME_3 = register("ms.registration.sign.first_name.3", "first name"); + public static final Translation REGISTRATION_SIGN_LAST_NAME_0 = register("ms.registration.sign.last_name.0", ""); + public static final Translation REGISTRATION_SIGN_LAST_NAME_1 = register("ms.registration.sign.last_name.1", "---===+===---"); + public static final Translation REGISTRATION_SIGN_LAST_NAME_2 = register("ms.registration.sign.last_name.2", "Type your"); + public static final Translation REGISTRATION_SIGN_LAST_NAME_3 = register("ms.registration.sign.last_name.3", "last name"); + public static final Translation REGISTRATION_SIGN_PATRONYMIC_0 = register("ms.registration.sign.patronymic.0", ""); + public static final Translation REGISTRATION_SIGN_PATRONYMIC_1 = register("ms.registration.sign.patronymic.1", "---===+===---"); + public static final Translation REGISTRATION_SIGN_PATRONYMIC_2 = register("ms.registration.sign.patronymic.2", "Type your"); + public static final Translation REGISTRATION_SIGN_PATRONYMIC_3 = register("ms.registration.sign.patronymic.3", "patronymic"); + public static final Translation REGISTRATION_MESSAGE_0 = register("ms.registration.message.0", "Oh..."); + public static final Translation REGISTRATION_MESSAGE_1 = register("ms.registration.message.1", "It's a very strange place"); + public static final Translation REGISTRATION_MESSAGE_2 = register("ms.registration.message.2", "Does that ring any bells?"); + public static final Translation REGISTRATION_MESSAGE_3 = register("ms.registration.message.3", "All right..."); + public static final Translation REGISTRATION_MESSAGE_4 = register("ms.registration.message.4", "I've seen you somewhere before"); + public static final Translation REGISTRATION_MESSAGE_5 = register("ms.registration.message.5", "What's your name again?"); + public static final Translation REGISTRATION_MESSAGE_6 = register("ms.registration.message.6", "Just be honest, or I'll mistakenly call you that for the rest of your life"); + public static final Translation REGISTRATION_MESSAGE_7 = register("ms.registration.message.7", "Interesting..."); + public static final Translation REGISTRATION_MESSAGE_8 = register("ms.registration.message.8", "In my life, I've seen a lot of people with that name"); + public static final Translation REGISTRATION_MESSAGE_9 = register("ms.registration.message.9", "But this is the first time I've seen you"); + public static final Translation REGISTRATION_MESSAGE_10 = register("ms.registration.message.10", "Can you please clarify your last name and patronymic?"); + public static final Translation REGISTRATION_MESSAGE_11 = register("ms.registration.message.11", "Well, that's great, §7[{0}] §f{1} {2} {3}"); + public static final Translation REGISTRATION_MESSAGE_12 = register("ms.registration.message.12", "Listen"); + public static final Translation REGISTRATION_MESSAGE_13 = register("ms.registration.message.13", "How should I address you?"); + public static final Translation REGISTRATION_MESSAGE_14 = register("ms.registration.message.14", "Nice"); + public static final Translation REGISTRATION_MESSAGE_15 = register("ms.registration.message.15", "Well..."); + public static final Translation REGISTRATION_MESSAGE_16 = register("ms.registration.message.16", "I have to go now"); + public static final Translation REGISTRATION_MESSAGE_17 = register("ms.registration.message.17", "Have a nice trip, {1}"); + public static final Translation CHAT_HOVER_NAME = register("ms.chat.hover_name", "Click to open this player's profile"); + public static final Translation CHAT_HOVER_MESSAGE = register("ms.chat.hover_message", "Click to write a PM to this player"); + public static final Translation CHAT_LOCAL_FORMAT = register("ms.chat.local.format", " {0} : {1}"); + public static final Translation CHAT_GLOBAL_FORMAT = register("ms.chat.global.format", " [WM] {0} : {1}"); + public static final Translation CHAT_PRIVATE_FORMAT_GLOBAL = register("ms.chat.private.format.global", " {0} -> {1} : {2}"); + public static final Translation CHAT_PRIVATE_FORMAT_SENDER = register("ms.chat.private.format.sender", " You -> {0} : {1}"); + public static final Translation CHAT_PRIVATE_FORMAT_RECEIVER = register("ms.chat.private.format.receiver", " {0} -> You : {1}"); + public static final Translation CHAT_DISCORD_FORMAT = register("ms.chat.discord.format", ' ' + SPEECH + " {0} : {1}"); + public static final Translation CHAT_DISCORD_FORMAT_REPLYING = register("ms.chat.discord.format.replying", ' ' + SPEECH + " {0} (replying to \"{1}\") : {2}"); + public static final Translation CHAT_DISCORD_FORMAT_GLOBAL_TO_LOCAL = register("ms.chat.discord.format.global_to_local", " [WM] {0} : {1}"); + public static final Translation CHAT_DISCORD_FORMAT_GLOBAL_TO_GLOBAL = register("ms.chat.discord.format.global_to_global", " {0} : {1}"); + public static final Translation CHAT_DISCORD_ATTACHMENT = register("ms.chat.discord.attachment", "(Attachment)"); + public static final Translation CHAT_DISCORD_ATTACHMENTS = register("ms.chat.discord.attachments", "(Attachments)"); + public static final Translation CHAT_ME_FORMAT = register("ms.chat.me.format", "* {0} {1} *"); + public static final Translation CHAT_DO_FORMAT = register("ms.chat.do.format", "* {0} * | {1}"); + public static final Translation CHAT_IT_FORMAT = register("ms.chat.it.format", "* {0} *"); + public static final Translation CHAT_TO_DO_FORMAT = register("ms.chat.to_do.format", "* {0} - {1} {2}, {3} *"); + public static final Translation CHAT_TRY_FORMAT = register("ms.chat.try.format", "* {0} {1} {2} *"); + public static final Translation CHAT_DEATH_FORMAT_UNO = register("ms.chat.death.format.uno", "{0} {1}"); + public static final Translation CHAT_DEATH_FORMAT_DUO = register("ms.chat.death.format.duo", "{0} {1} {2}"); + public static final Translation CHAT_JOIN_FORMAT = register("ms.chat.join.format", "{0} {1}"); + public static final Translation CHAT_QUIT_FORMAT = register("ms.chat.quit.format", "{0} {1}"); + public static final Translation PLAYER_NAME_NICKNAME = register("ms.player.name.nickname", "Steve"); + public static final Translation PLAYER_NAME_FIRST_NAME = register("ms.player.name.first_name", "John"); + public static final Translation PLAYER_NAME_LAST_NAME = register("ms.player.name.last_name", "Doe"); + public static final Translation PLAYER_NAME_PATRONYMIC = register("ms.player.name.patronymic", "Smith"); + public static final Translation PLAYER_PRONOUNS_HE_JOIN = register("ms.player.pronouns.he.join", "joined the server"); + public static final Translation PLAYER_PRONOUNS_HE_QUIT = register("ms.player.pronouns.he.quit", "left the server"); + public static final Translation PLAYER_PRONOUNS_HE_SPIT = register("ms.player.pronouns.he.spit", "spit"); + public static final Translation PLAYER_PRONOUNS_HE_FART = register("ms.player.pronouns.he.fart", "fart"); + public static final Translation PLAYER_PRONOUNS_HE_PRONOUNS = register("ms.player.pronouns.he.pronouns", "you"); + public static final Translation PLAYER_PRONOUNS_HE_TRAVELER = register("ms.player.pronouns.he.traveler", "traveler"); + public static final Translation PLAYER_PRONOUNS_HE_SIT = register("ms.player.pronouns.he.sit", "sat"); + public static final Translation PLAYER_PRONOUNS_HE_GET_UP = register("ms.player.pronouns.he.get_up", "got up"); + public static final Translation PLAYER_PRONOUNS_HE_DEATH = register("ms.player.pronouns.he.death", "died"); + public static final Translation PLAYER_PRONOUNS_HE_KILL = register("ms.player.pronouns.he.kill", "killed"); + public static final Translation PLAYER_PRONOUNS_HE_SAID = register("ms.player.pronouns.he.said", "said"); + public static final Translation PLAYER_PRONOUNS_SHE_JOIN = register("ms.player.pronouns.she.join", "joined the server"); + public static final Translation PLAYER_PRONOUNS_SHE_QUIT = register("ms.player.pronouns.she.quit", "left the server"); + public static final Translation PLAYER_PRONOUNS_SHE_SPIT = register("ms.player.pronouns.she.spit", "spit"); + public static final Translation PLAYER_PRONOUNS_SHE_FART = register("ms.player.pronouns.she.fart", "fart"); + public static final Translation PLAYER_PRONOUNS_SHE_PRONOUNS = register("ms.player.pronouns.she.pronouns", "you"); + public static final Translation PLAYER_PRONOUNS_SHE_TRAVELER = register("ms.player.pronouns.she.traveler", "traveler"); + public static final Translation PLAYER_PRONOUNS_SHE_SIT = register("ms.player.pronouns.she.sit", "sat"); + public static final Translation PLAYER_PRONOUNS_SHE_GET_UP = register("ms.player.pronouns.she.get_up", "got up"); + public static final Translation PLAYER_PRONOUNS_SHE_DEATH = register("ms.player.pronouns.she.death", "died"); + public static final Translation PLAYER_PRONOUNS_SHE_KILL = register("ms.player.pronouns.she.kill", "killed"); + public static final Translation PLAYER_PRONOUNS_SHE_SAID = register("ms.player.pronouns.she.said", "said"); + public static final Translation PLAYER_PRONOUNS_THEY_JOIN = register("ms.player.pronouns.they.join", "joined the server"); + public static final Translation PLAYER_PRONOUNS_THEY_QUIT = register("ms.player.pronouns.they.quit", "left the server"); + public static final Translation PLAYER_PRONOUNS_THEY_SPIT = register("ms.player.pronouns.they.spit", "spit"); + public static final Translation PLAYER_PRONOUNS_THEY_FART = register("ms.player.pronouns.they.fart", "fart"); + public static final Translation PLAYER_PRONOUNS_THEY_PRONOUNS = register("ms.player.pronouns.they.pronouns", "you"); + public static final Translation PLAYER_PRONOUNS_THEY_TRAVELER = register("ms.player.pronouns.they.traveler", "traveler"); + public static final Translation PLAYER_PRONOUNS_THEY_SIT = register("ms.player.pronouns.they.sit", "sat"); + public static final Translation PLAYER_PRONOUNS_THEY_GET_UP = register("ms.player.pronouns.they.get_up", "got up"); + public static final Translation PLAYER_PRONOUNS_THEY_DEATH = register("ms.player.pronouns.they.death", "died"); + public static final Translation PLAYER_PRONOUNS_THEY_KILL = register("ms.player.pronouns.they.kill", "killed"); + public static final Translation PLAYER_PRONOUNS_THEY_SAID = register("ms.player.pronouns.they.said", "said"); + // + + @Contract(" -> fail") + private Translations() throws AssertionError { + throw new AssertionError("Utility class"); + } + + private static @NotNull Translation register( + final @NotNull String key, + final @Nullable String translation + ) { + return translation == null + ? registry().registerKey(key) + : registry().register( + key, + SharedConstants.DEFAULT_LOCALE, + translation + ); + } +} diff --git a/src/main/java/com/minersstudios/mscore/locale/resource/FileTranslationResourceManager.java b/src/main/java/com/minersstudios/mscore/locale/resource/FileTranslationResourceManager.java new file mode 100644 index 00000000..16f056fd --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/locale/resource/FileTranslationResourceManager.java @@ -0,0 +1,13 @@ +package com.minersstudios.mscore.locale.resource; + +import com.minersstudios.mscore.resource.file.AbstractFileResourceManager; +import org.jetbrains.annotations.NotNull; + +import java.io.File; + +public final class FileTranslationResourceManager extends AbstractFileResourceManager implements TranslationResourceManager { + + FileTranslationResourceManager(final @NotNull File file) { + super(file); + } +} diff --git a/src/main/java/com/minersstudios/mscore/locale/resource/GitHubTranslationResourceManager.java b/src/main/java/com/minersstudios/mscore/locale/resource/GitHubTranslationResourceManager.java new file mode 100644 index 00000000..cf58d930 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/locale/resource/GitHubTranslationResourceManager.java @@ -0,0 +1,40 @@ +package com.minersstudios.mscore.locale.resource; + +import com.minersstudios.mscore.resource.github.AbstractGithubResourceManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.net.URI; + +public final class GitHubTranslationResourceManager extends AbstractGithubResourceManager implements TranslationResourceManager { + private final String folderPath; + + private static final String DOWNLOAD_TRANSLATION_URL = "https://raw.githubusercontent.com/%s/%s/%s/%s"; + + GitHubTranslationResourceManager( + final @NotNull File file, + final @NotNull String user, + final @NotNull String repo, + final @Nullable String currentTag, + final @Nullable String token, + final @Nullable String folderPath + ) { + super(file, user, repo, currentTag, token); + + this.folderPath = folderPath; + } + + + @Override + public @NotNull URI getFileUri(final @NotNull String tag) { + return URI.create( + DOWNLOAD_TRANSLATION_URL.formatted( + this.user, this.repo, tag, + this.folderPath == null + ? this.file.getName() + : this.folderPath + "/" + this.file.getName() + ) + ); + } +} diff --git a/src/main/java/com/minersstudios/mscore/locale/resource/TranslationResourceManager.java b/src/main/java/com/minersstudios/mscore/locale/resource/TranslationResourceManager.java new file mode 100644 index 00000000..4d69ba03 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/locale/resource/TranslationResourceManager.java @@ -0,0 +1,107 @@ +package com.minersstudios.mscore.locale.resource; + +import com.minersstudios.mscore.resource.ResourceManager; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.net.URI; + +public interface TranslationResourceManager extends ResourceManager { + + /** + * Creates a new resource manager for the given url + * + * @param url The url of the translation file + * @return The resource manager for the given url + * @throws IllegalArgumentException If the given string violates + * RFC 2396 + * @see #uri(URI) + */ + @Contract("_ -> new") + static @NotNull URITranslationResourceManager url(final @NotNull String url) throws IllegalArgumentException { + return uri(URI.create(url)); + } + + /** + * Creates a new resource manager for the given URI + * + * @param uri The URI of the translation file + * @return The resource manager for the given URI + */ + @Contract("_ -> new") + static @NotNull URITranslationResourceManager uri(final @NotNull URI uri) { + return new URITranslationResourceManager(uri); + } + + /** + * Creates a new resource manager for the given file + * + * @param file The file of the translation file + * @return The resource manager for the given file + */ + @Contract("_ -> new") + static @NotNull FileTranslationResourceManager file(final @NotNull File file) { + return new FileTranslationResourceManager(file); + } + + /** + * Creates a new resource manager for the given GitHub repository + * + * @param file The file to download translation file to + * @param user The GitHub user + * @param repo The GitHub repository + * @return The resource manager for the given GitHub repository + */ + @Contract("_, _, _ -> new") + static @NotNull GitHubTranslationResourceManager github( + final @NotNull File file, + final @NotNull String user, + final @NotNull String repo + ) { + return github(file, user, repo, null, null, null); + } + + /** + * Creates a new resource manager for the given GitHub repository + * + * @param file The file to download translation file to + * @param user The GitHub user + * @param repo The GitHub repository + * @param folderPath The path of the translation folder + * @return The resource manager for the given GitHub repository + */ + @Contract("_, _, _, _ -> new") + static @NotNull GitHubTranslationResourceManager github( + final @NotNull File file, + final @NotNull String user, + final @NotNull String repo, + final @Nullable String folderPath + ) { + return github(file, user, repo, null, null, folderPath); + } + + /** + * Creates a new resource manager for the given GitHub repository + * + * @param file The file to download the translation file to + * @param user The GitHub user + * @param repo The GitHub repository + * @param currentTag The current saved tag of the translation file + * @param token The GitHub token + * @param folderPath The path of the translation folder + * @return The resource manager for the given GitHub repository + */ + @Contract("_, _, _, _, _, _ -> new") + static @NotNull GitHubTranslationResourceManager github( + final @NotNull File file, + final @NotNull String user, + final @NotNull String repo, + final @Nullable String currentTag, + final @Nullable String token, + final @Nullable String folderPath + ) { + return new GitHubTranslationResourceManager(file, user, repo, currentTag, token, folderPath); + } +} diff --git a/src/main/java/com/minersstudios/mscore/locale/resource/URITranslationResourceManager.java b/src/main/java/com/minersstudios/mscore/locale/resource/URITranslationResourceManager.java new file mode 100644 index 00000000..5c40e42e --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/locale/resource/URITranslationResourceManager.java @@ -0,0 +1,13 @@ +package com.minersstudios.mscore.locale.resource; + +import com.minersstudios.mscore.resource.uri.AbstractURIResourceManager; +import org.jetbrains.annotations.NotNull; + +import java.net.URI; + +public final class URITranslationResourceManager extends AbstractURIResourceManager implements TranslationResourceManager { + + URITranslationResourceManager(final @NotNull URI uri) { + super(uri); + } +} diff --git a/src/main/java/com/minersstudios/mscore/plugin/GlobalConfig.java b/src/main/java/com/minersstudios/mscore/plugin/GlobalConfig.java index 6b0a5683..fbd72ac5 100644 --- a/src/main/java/com/minersstudios/mscore/plugin/GlobalConfig.java +++ b/src/main/java/com/minersstudios/mscore/plugin/GlobalConfig.java @@ -1,11 +1,23 @@ package com.minersstudios.mscore.plugin; -import com.minersstudios.mscore.utility.SharedConstants; -import com.minersstudios.mscore.language.LanguageFile; +import com.minersstudios.mscore.locale.LanguageFile; +import com.minersstudios.mscore.locale.TranslationRegistry; import com.minersstudios.mscore.plugin.config.MSConfig; +import com.minersstudios.mscore.utility.ChatUtils; +import com.minersstudios.mscore.utility.SharedConstants; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.kyori.adventure.translation.Translator; +import org.bukkit.configuration.ConfigurationSection; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnknownNullability; import java.io.File; import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Locale; +import java.util.concurrent.CompletableFuture; + +import static net.kyori.adventure.text.Component.text; /** * Configuration loader class. @@ -14,92 +26,166 @@ * configuration. */ public final class GlobalConfig extends MSConfig { - private String languageCode; - private String languageFolderLink; - private String timeFormat; - private DateTimeFormatter timeFormatter; + private String dateFormat; private boolean isChristmas; private boolean isHalloween; + private String languageDefaultCode; - public static final String FILE_PATH = SharedConstants.GLOBAL_FOLDER_PATH + "config.yml"; + private DateTimeFormatter dateFormatter; + private Locale defaultLocale; + private List locales; - /** - * Global configuration constructor. - * All variables must be initialized in {@link #reloadVariables()} - */ - public GlobalConfig() { - super(new File(FILE_PATH)); + // + public static final String KEY_DATE_FORMAT = "date-format"; + public static final String KEY_IS_CHRISTMAS = "is-christmas"; + public static final String KEY_IS_HALLOWEEN = "is-halloween"; + + public static final String KEY_LANGUAGE_SECTION = "language"; + public static final String KEY_DEFAULT_CODE = "default-code"; + public static final String KEY_CODES = "codes"; + // + + private static final String JSON_EXTENSION = ".json"; + + GlobalConfig() { + super(new File(SharedConstants.GLOBAL_FOLDER_PATH + "config.yml")); } - /** - * Reloads config variables. - *
- * NOTE: Not updates the {@link LanguageFile}. Use - * {@link LanguageFile#reloadLanguage()} to reload language file. - */ public void reloadVariables() { - this.languageCode = this.yaml.getString("language.code"); - this.languageFolderLink = this.yaml.getString("language.folder-link"); - this.timeFormat = this.yaml.getString("date-format"); - this.timeFormatter = DateTimeFormatter.ofPattern( - this.timeFormat == null + this.dateFormat = this.yaml.getString(KEY_DATE_FORMAT); + this.isChristmas = this.yaml.getBoolean(KEY_IS_CHRISTMAS); + this.isHalloween = this.yaml.getBoolean(KEY_IS_HALLOWEEN); + + final ConfigurationSection languageSection = this.yaml.getConfigurationSection(KEY_LANGUAGE_SECTION); + + if (languageSection == null) { + throw new IllegalStateException("Language section cannot be null"); + } + + this.languageDefaultCode = languageSection.getString(KEY_DEFAULT_CODE); + + this.dateFormatter = DateTimeFormatter.ofPattern( + ChatUtils.isBlank(this.dateFormat) ? SharedConstants.DATE_FORMAT - : this.timeFormat + : this.dateFormat ); - this.isChristmas = this.yaml.getBoolean("is-christmas"); - this.isHalloween = this.yaml.getBoolean("is-halloween"); + this.defaultLocale = Translator.parseLocale(this.languageDefaultCode); + + if (this.defaultLocale == null) { + this.defaultLocale = SharedConstants.DEFAULT_LOCALE; + } + + this.locales = new ObjectArrayList<>(); + + this.locales.add(this.defaultLocale); + + for (final var tag : languageSection.getStringList(KEY_CODES)) { + final Locale locale = Translator.parseLocale(tag); + + if (locale == null) { + MSLogger.warning("Invalid language tag: " + tag); + } else { + this.locales.add(locale); + } + } + + this.loadLanguages(); + } + + public void reloadDefaultVariables() { + this.setIfNotExists(KEY_DATE_FORMAT, SharedConstants.DATE_FORMAT); + this.setIfNotExists(KEY_IS_CHRISTMAS, false); + this.setIfNotExists(KEY_IS_HALLOWEEN, false); + this.setIfNotExists(KEY_LANGUAGE_SECTION + '.' + KEY_DEFAULT_CODE, SharedConstants.DEFAULT_LANGUAGE_CODE); } /** - * Reloads default config variables + * @return Time format */ - public void reloadDefaultVariables() { - this.setIfNotExists("language.code", SharedConstants.LANGUAGE_CODE); - this.setIfNotExists("language.folder-link", SharedConstants.LANGUAGE_FOLDER_LINK); - this.setIfNotExists("date-format", SharedConstants.DATE_FORMAT); - this.setIfNotExists("is-christmas", false); - this.setIfNotExists("is-halloween", false); + public @Nullable String getDateFormat() { + return this.dateFormat; } /** - * @return Time formatter + * @return True if it is Christmas */ - public String getLanguageCode() { - return this.languageCode; + public boolean isChristmas() { + return this.isChristmas; } /** - * @return Language folder link + * @return True if it is Halloween */ - public String getLanguageFolderLink() { - return this.languageFolderLink; + public boolean isHalloween() { + return this.isHalloween; } /** - * @return Time format + * @return Language tag */ - public String getTimeFormat() { - return this.timeFormat; + public @UnknownNullability String getLanguageDefaultCode() { + return this.languageDefaultCode; } /** - * @return Time formatter + * @return Date formatter */ - public DateTimeFormatter getTimeFormatter() { - return this.timeFormatter; + public @UnknownNullability DateTimeFormatter getDateFormatter() { + return this.dateFormatter; } /** - * @return True if it is Christmas + * @return Default locale */ - public boolean isChristmas() { - return this.isChristmas; + public @UnknownNullability Locale getDefaultLocale() { + return this.defaultLocale; } /** - * @return True if it is Halloween + * @return Locales */ - public boolean isHalloween() { - return this.isHalloween; + public @UnknownNullability List getLocales() { + return this.locales; + } + + private void loadLanguages() { + final ConfigurationSection languageSection = + this.yaml.getConfigurationSection(KEY_LANGUAGE_SECTION + '.' + KEY_CODES); + + if (languageSection != null) { + final long start = System.currentTimeMillis(); + + CompletableFuture + .allOf( + LanguageFile + .allFromSection( + this.file, + this.yaml, + languageSection, + languageFile -> { + TranslationRegistry.registry().registerAll(languageFile); + MSLogger.fine( + text("Loaded language : ") + .append(text(languageFile.getLocale().getDisplayName())) + .append(text(" with ")) + .append(text(String.valueOf(languageFile.size()))) + .append(text(" translations in ")) + .append(text(System.currentTimeMillis() - start)) + .append(text("ms")) + ); + }, + (localeTag, throwable) -> + MSLogger.warning( + text("Failed to load language \"") + .append(text(localeTag)) + .append(text('"')), + throwable + ) + ) + .values() + .toArray(CompletableFuture[]::new) + ) + .thenRun(TranslationRegistry::registerGlobal); + } } } diff --git a/src/main/java/com/minersstudios/mscore/plugin/MSLogger.java b/src/main/java/com/minersstudios/mscore/plugin/MSLogger.java index 97d2031b..1981d335 100644 --- a/src/main/java/com/minersstudios/mscore/plugin/MSLogger.java +++ b/src/main/java/com/minersstudios/mscore/plugin/MSLogger.java @@ -1,6 +1,6 @@ package com.minersstudios.mscore.plugin; -import com.minersstudios.mscore.language.LanguageFile; +import com.minersstudios.mscore.locale.TranslationRegistry; import com.minersstudios.mscore.utility.Font; import io.papermc.paper.adventure.PaperAdventure; import net.kyori.adventure.text.Component; @@ -39,15 +39,15 @@ public final class MSLogger { private static final String NAME = "MS"; private static final Logger LOGGER = Logger.getLogger(NAME); - private static final String ANSI_LIME = "\u001B[92m"; + private static final String ANSI_LIME = "\u001B[92m"; private static final String ANSI_RESET = "\u001B[0m"; - private static final int SEVERE = 1000; + private static final int SEVERE = 1000; private static final int WARNING = 900; - private static final int FINE = 500; + private static final int FINE = 500; @Contract(" -> fail") - private MSLogger() { + private MSLogger() throws AssertionError { throw new AssertionError("This class cannot be instantiated!"); } @@ -222,7 +222,7 @@ public static void logChat( } else if (target instanceof BlockCommandSender) { target.sendMessage( message instanceof final TranslatableComponent translatableComponent - ? LanguageFile.renderTranslationComponent(translatableComponent) + ? TranslationRegistry.renderComponent(translatableComponent) : message ); } else { diff --git a/src/main/java/com/minersstudios/mscore/plugin/MSPlugin.java b/src/main/java/com/minersstudios/mscore/plugin/MSPlugin.java index 7cdf52ae..75c8d246 100644 --- a/src/main/java/com/minersstudios/mscore/plugin/MSPlugin.java +++ b/src/main/java/com/minersstudios/mscore/plugin/MSPlugin.java @@ -2,23 +2,22 @@ import com.google.common.base.Charsets; import com.minersstudios.mscore.command.api.AbstractCommandExecutor; -import com.minersstudios.mscore.command.api.MSCommand; import com.minersstudios.mscore.command.api.Commodore; +import com.minersstudios.mscore.command.api.MSCommand; import com.minersstudios.mscore.inventory.plugin.AbstractInventoryHolder; import com.minersstudios.mscore.inventory.plugin.InventoryHolder; -import com.minersstudios.mscore.language.LanguageFile; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.listener.api.event.AbstractEventListener; import com.minersstudios.mscore.listener.api.event.EventListener; import com.minersstudios.mscore.listener.api.packet.AbstractPacketListener; import com.minersstudios.mscore.listener.api.packet.PacketListener; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.packet.PacketEvent; import com.minersstudios.mscore.packet.PacketListenersMap; import com.minersstudios.mscore.packet.PacketRegistry; import com.minersstudios.mscore.packet.PacketType; -import com.minersstudios.mscore.plugin.status.PluginStatus; -import com.minersstudios.mscore.plugin.status.StatusHandler; -import com.minersstudios.mscore.plugin.status.SuccessStatus; +import com.minersstudios.mscore.status.Status; +import com.minersstudios.mscore.status.StatusHandler; +import com.minersstudios.mscore.status.SuccessStatus; import com.minersstudios.mscore.utility.*; import com.mojang.brigadier.tree.LiteralCommandNode; import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap; @@ -55,8 +54,8 @@ import java.util.logging.Level; import java.util.logging.Logger; -import static com.minersstudios.mscore.plugin.status.SuccessStatus.high; -import static com.minersstudios.mscore.plugin.status.SuccessStatus.low; +import static com.minersstudios.mscore.status.Status.successHigh; +import static com.minersstudios.mscore.status.Status.successLow; import static net.kyori.adventure.text.Component.text; /** @@ -81,37 +80,34 @@ public abstract class MSPlugin> extends JavaPlugin { private Commodore commodore; private FileConfiguration newConfig; - private static final Field DATA_FOLDER_FIELD; - private static final Constructor COMMAND_CONSTRUCTOR; - - // - private static final File GLOBAL_FOLDER; - private static final GlobalCache GLOBAL_CACHE; - private static final GlobalConfig GLOBAL_CONFIG; - // - // /** High-priority plugin initializing status */ - public static final SuccessStatus INITIALIZING = high("INITIALIZING"); + public static final SuccessStatus INITIALIZING = successHigh("INITIALIZING"); /** Low-priority plugin initialized status */ - public static final SuccessStatus INITIALIZED = low("INITIALIZED"); + public static final SuccessStatus INITIALIZED = successLow("INITIALIZED"); /** High-priority plugin loading status */ - public static final SuccessStatus LOADING = high("LOADING"); + public static final SuccessStatus LOADING = successHigh("LOADING"); /** Low-priority plugin loaded status */ - public static final SuccessStatus LOADED = low("LOADED"); + public static final SuccessStatus LOADED = successLow("LOADED"); /** High-priority plugin enabling status */ - public static final SuccessStatus ENABLING = high("ENABLING"); + public static final SuccessStatus ENABLING = successHigh("ENABLING"); /** High-priority plugin enabled status */ - public static final SuccessStatus ENABLED = high("ENABLED"); + public static final SuccessStatus ENABLED = successHigh("ENABLED"); /** High-priority plugin disabling status */ - public static final SuccessStatus DISABLING = high("DISABLING"); + public static final SuccessStatus DISABLING = successHigh("DISABLING"); /** High-priority plugin disabled status */ - public static final SuccessStatus DISABLED = high("DISABLED"); + public static final SuccessStatus DISABLED = successHigh("DISABLED"); // + private static final Field DATA_FOLDER_FIELD; + private static final Constructor COMMAND_CONSTRUCTOR; + private static final File GLOBAL_FOLDER; + private static final GlobalCache GLOBAL_CACHE; + private static final GlobalConfig GLOBAL_CONFIG; + static { GLOBAL_FOLDER = new File(SharedConstants.GLOBAL_FOLDER_PATH); GLOBAL_CACHE = new GlobalCache(); @@ -122,10 +118,6 @@ public abstract class MSPlugin> extends JavaPlugin { } GLOBAL_CONFIG.reload(); - LanguageFile.loadLanguage( - GLOBAL_CONFIG.getLanguageFolderLink(), - GLOBAL_CONFIG.getLanguageCode() - ); try { DATA_FOLDER_FIELD = JavaPlugin.class.getDeclaredField("dataFolder"); @@ -139,9 +131,7 @@ public abstract class MSPlugin> extends JavaPlugin { throw new IllegalStateException("Could not find command constructor", e); } - initClass(LanguageRegistry.Keys.class); - initClass(LanguageRegistry.Components.class); - initClass(LanguageRegistry.Strings.class); + initClass(Translations.class); initClass(PacketRegistry.class); initClass(Font.class); initClass(BlockUtils.class); @@ -153,7 +143,7 @@ public abstract class MSPlugin> extends JavaPlugin { protected MSPlugin() { this.statusHandler = new StatusHandler(); - this.setStatus(INITIALIZING); + this.assignStatus(INITIALIZING); this.classNames = this.loadClassNames(SharedConstants.GLOBAL_PACKAGE + '.' + this.getName().toLowerCase()); this.commandMap = new Object2ObjectOpenHashMap<>(); @@ -166,15 +156,10 @@ protected MSPlugin() { try { DATA_FOLDER_FIELD.set(this, this.pluginFolder); } catch (final Throwable e) { - this.getLogger().log( - Level.SEVERE, - "Could not set data folder", - e - ); - this.getServer().getPluginManager().disablePlugin(this); + throw new IllegalStateException("Could not set data folder", e); } - this.setStatus(INITIALIZED); + this.assignStatus(INITIALIZED); } /** @@ -189,19 +174,19 @@ protected MSPlugin() { * otherwise an empty optional * @see StatusHandler */ - public final @NotNull Optional getStatus() { + public final @NotNull Optional getStatus() { return this.statusHandler.getHighStatus(); } /** - * Sets the specified status and runs all the registered watchers with this - * status + * Assigns the specified status and runs all the registered watchers with + * this status * - * @param status Status to be set + * @param status Status to be assigned * @see StatusHandler */ - public final void setStatus(final @NotNull PluginStatus status) { - this.statusHandler.setStatus(status); + public final void assignStatus(final @NotNull Status status) { + this.statusHandler.assignStatus(status); } /** @@ -295,7 +280,7 @@ public final void setStatus(final @NotNull PluginStatus status) { * @return True if the status is present, false otherwise * @see StatusHandler */ - public boolean containsStatus(final @NotNull PluginStatus status) { + public boolean containsStatus(final @NotNull Status status) { return this.statusHandler.contains(status); } @@ -306,8 +291,8 @@ public boolean containsStatus(final @NotNull PluginStatus status) { * @see StatusHandler */ public boolean containsAnyStatus( - final @NotNull PluginStatus first, - final PluginStatus @NotNull ... rest + final @NotNull Status first, + final Status @NotNull ... rest ) { return this.statusHandler.containsAny(first, rest); } @@ -321,8 +306,8 @@ public boolean containsAnyStatus( * @see StatusHandler */ public boolean containsAllStatuses( - final @NotNull PluginStatus first, - final PluginStatus @NotNull ... rest + final @NotNull Status first, + final Status @NotNull ... rest ) throws IllegalArgumentException { return this.statusHandler.containsAll(first, rest); } @@ -340,10 +325,10 @@ public boolean containsAllStatuses( public final void onLoad() { final long time = System.currentTimeMillis(); - this.setStatus(LOADING); + this.assignStatus(LOADING); this.loadAnnotated(); this.load(); - this.setStatus(LOADED); + this.assignStatus(LOADED); this.getComponentLogger() .info( @@ -369,7 +354,7 @@ public final void onLoad() { public final void onEnable() { final long time = System.currentTimeMillis(); - this.setStatus(ENABLING); + this.assignStatus(ENABLING); this.commodore = new Commodore(this); @@ -378,7 +363,7 @@ public final void onEnable() { this.registerInventoryHolders(); this.registerCommands(); this.enable(); - this.setStatus(ENABLED); + this.assignStatus(ENABLED); if (this.isEnabled()) { this.getComponentLogger() @@ -400,9 +385,9 @@ public final void onEnable() { public final void onDisable() { final long time = System.currentTimeMillis(); - this.setStatus(DISABLING); + this.assignStatus(DISABLING); this.disable(); - this.setStatus(DISABLED); + this.assignStatus(DISABLED); this.getComponentLogger() .info( @@ -1024,7 +1009,7 @@ private void loadAnnotation( ); } } catch (final Throwable e) { - logger.log(Level.SEVERE, "Failed to annotated class : " + givenClass.getName(), e); + throw new IllegalStateException("Failed to load annotated class : " + givenClass.getName(), e); } } @@ -1174,8 +1159,7 @@ private void registerCommands() { } } } catch (final Throwable e) { - MSLogger.severe("Failed to load class names", e); - this.getServer().getPluginManager().disablePlugin(this); + throw new IllegalStateException("Failed to load class names", e); } return classNames; diff --git a/src/main/java/com/minersstudios/mscore/plugin/cache/MSCache.java b/src/main/java/com/minersstudios/mscore/plugin/cache/MSCache.java index 24ce132e..803ac041 100644 --- a/src/main/java/com/minersstudios/mscore/plugin/cache/MSCache.java +++ b/src/main/java/com/minersstudios/mscore/plugin/cache/MSCache.java @@ -1,7 +1,9 @@ package com.minersstudios.mscore.plugin.cache; +import org.jetbrains.annotations.NotNull; + public abstract class MSCache { - private boolean loaded; + private boolean isLoaded; /** * Loads the cache @@ -13,7 +15,7 @@ public final void load() throws IllegalStateException { throw new IllegalStateException("Cache is already loaded"); } - this.loaded = true; + this.isLoaded = true; this.onLoad(); } @@ -27,15 +29,27 @@ public final void unload() throws IllegalStateException { throw new IllegalStateException("Cache is not loaded"); } - this.loaded = false; + this.isLoaded = false; this.onUnload(); } /** + * Returns whether the cache is loaded + * * @return Whether the cache is loaded */ public final boolean isLoaded() { - return this.loaded; + return this.isLoaded; + } + + /** + * Returns a string representation of this cache + * + * @return A string representation of this cache + */ + @Override + public @NotNull String toString() { + return this.getClass().getSimpleName() + "{isLoaded=" + this.isLoaded + "}"; } /** diff --git a/src/main/java/com/minersstudios/mscore/plugin/cache/PluginCache.java b/src/main/java/com/minersstudios/mscore/plugin/cache/PluginCache.java index 15328bf1..cade76b4 100644 --- a/src/main/java/com/minersstudios/mscore/plugin/cache/PluginCache.java +++ b/src/main/java/com/minersstudios/mscore/plugin/cache/PluginCache.java @@ -2,7 +2,6 @@ import com.minersstudios.mscore.plugin.MSPlugin; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.UnknownNullability; /** * This abstract class represents a cache for a plugin. It provides methods to @@ -23,9 +22,24 @@ protected PluginCache(final @NotNull P plugin) { } /** - * @return The plugin that owns this cache or null if the cache is not loaded + * Returns the plugin that owns this cache + * + * @return The plugin that owns this cache */ - public final @UnknownNullability P getPlugin() { + public final @NotNull P getPlugin() { return this.plugin; } + + /** + * Returns a string representation of this cache + * + * @return A string representation of this cache + */ + @Override + public @NotNull String toString() { + return this.getClass().getSimpleName() + + "{plugin=" + this.plugin.getName() + + ", isLoaded=" + this.isLoaded() + + '}'; + } } diff --git a/src/main/java/com/minersstudios/mscore/plugin/status/FailureStatus.java b/src/main/java/com/minersstudios/mscore/plugin/status/FailureStatus.java deleted file mode 100644 index 237212c2..00000000 --- a/src/main/java/com/minersstudios/mscore/plugin/status/FailureStatus.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.minersstudios.mscore.plugin.status; - -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; - -import javax.annotation.concurrent.Immutable; -import java.util.Locale; - -@Immutable -public final class FailureStatus extends ImplPluginStatus { - - private FailureStatus( - final @NotNull String name, - final @NotNull Priority priority - ) { - super(name, priority); - } - - /** - * Creates a new status failure with the specified name and low priority - * - * @param name Name of the failure status - * @return A new failure status with the specified name and low priority - * @throws IllegalArgumentException If the name does not match the name - * regex - * @see #validateName(String) - */ - @Contract("_ -> new") - public static @NotNull FailureStatus low(final @NotNull String name) throws IllegalArgumentException { - final String nameUpper = name.toUpperCase(Locale.ENGLISH); - - PluginStatus.validateName(nameUpper); - - return new FailureStatus( - nameUpper, - Priority.LOW - ); - } - - /** - * Creates a new status failure with the specified name and medium priority - * - * @param name Name of the failure status - * @return A new failure status with the specified name and medium priority - * @throws IllegalArgumentException If the name does not match the name - * regex - * @see #validateName(String) - */ - @Contract("_ -> new") - public static @NotNull FailureStatus high(final @NotNull String name) throws IllegalArgumentException { - final String nameUpper = name.toUpperCase(Locale.ENGLISH); - - PluginStatus.validateName(nameUpper); - - return new FailureStatus( - nameUpper, - Priority.HIGH - ); - } -} diff --git a/src/main/java/com/minersstudios/mscore/plugin/status/ImplPluginStatus.java b/src/main/java/com/minersstudios/mscore/plugin/status/ImplPluginStatus.java deleted file mode 100644 index 096369c3..00000000 --- a/src/main/java/com/minersstudios/mscore/plugin/status/ImplPluginStatus.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.minersstudios.mscore.plugin.status; - -import org.jetbrains.annotations.NotNull; - -import javax.annotation.concurrent.Immutable; -import java.util.Objects; - -@Immutable -abstract class ImplPluginStatus implements PluginStatus { - private final String name; - private final PluginStatus.Priority priority; - - protected ImplPluginStatus( - final @NotNull String name, - final @NotNull Priority priority - ) { - this.name = name; - this.priority = priority; - } - - @Override - public final @NotNull String getName() { - return this.name; - } - - @Override - public final @NotNull Priority getPriority() { - return this.priority; - } - - @Override - public final boolean isHighPriority() { - return this.priority == Priority.HIGH; - } - - @Override - public final boolean isLowPriority() { - return this.priority == Priority.LOW; - } - - @Override - public int hashCode() { - return Objects.hash(this.name, this.priority); - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - - if (obj.getClass() != this.getClass()) { - return false; - } - - final ImplPluginStatus that = (ImplPluginStatus) obj; - - return this.name.equals(that.name) - && this.priority == that.priority; - } - - @Override - public @NotNull String toString() { - return this.name + '{' + this.priority + '}'; - } -} diff --git a/src/main/java/com/minersstudios/mscore/plugin/status/PluginStatus.java b/src/main/java/com/minersstudios/mscore/plugin/status/PluginStatus.java deleted file mode 100644 index a42ac856..00000000 --- a/src/main/java/com/minersstudios/mscore/plugin/status/PluginStatus.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.minersstudios.mscore.plugin.status; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.regex.Pattern; - -public interface PluginStatus { - String REGEX = "^[A-Z0-9_]+$"; - Pattern PATTERN = Pattern.compile(REGEX); - - /** - * @return The name of the status - */ - @NotNull String getName(); - - /** - * @return The priority of the status - */ - @NotNull Priority getPriority(); - - /** - * @return True if the status is a high priority - */ - boolean isHighPriority(); - - /** - * @return True if the status is a low priority - */ - boolean isLowPriority(); - - /** - * @return Hash code of the status - */ - @Override - int hashCode(); - - /** - * @param obj The object to compare - * @return True if the object is equal to this status - */ - @Override - boolean equals(final @Nullable Object obj); - - /** - * @return A string representation of the status - */ - @Override - @NotNull String toString(); - - /** - * @param name Name of the status - * @return True if the name matches the {@link #REGEX regex} - */ - static boolean matchesNameRegex(final @NotNull String name) { - return PATTERN.matcher(name).matches(); - } - - /** - * Validates the name of the status - * - * @param name Name of the status - * @throws IllegalArgumentException If the name does not match the - * {@link #REGEX regex} - */ - static void validateName(final @NotNull String name) throws IllegalArgumentException { - if (!matchesNameRegex(name)) { - throw new IllegalArgumentException("Name must match regex: " + REGEX); - } - } - - /** - * Validates the failure status - * - * @param mainPriority The priority of the main status - * @param failureStatus The failure status, that adds to the main status - * @throws IllegalArgumentException If the failure status has a different - * priority than the main status - */ - static void validateFailureStatus( - final @NotNull Priority mainPriority, - final @Nullable FailureStatus failureStatus - ) throws IllegalArgumentException { - if ( - failureStatus != null - && failureStatus.getPriority() != mainPriority - ) { - throw new IllegalArgumentException( - "Failure status must have the same priority as the main status" - ); - } - } - - enum Priority { - LOW, HIGH - } -} diff --git a/src/main/java/com/minersstudios/mscore/plugin/status/SuccessStatus.java b/src/main/java/com/minersstudios/mscore/plugin/status/SuccessStatus.java deleted file mode 100644 index 4957217f..00000000 --- a/src/main/java/com/minersstudios/mscore/plugin/status/SuccessStatus.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.minersstudios.mscore.plugin.status; - -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.annotation.concurrent.Immutable; -import java.util.Locale; - -@Immutable -public final class SuccessStatus extends ImplPluginStatus { - private final FailureStatus failureStatus; - - private SuccessStatus( - final @NotNull String name, - final @NotNull Priority priority, - final @Nullable FailureStatus failureStatus - ) { - super(name, priority); - - this.failureStatus = failureStatus; - } - - /** - * Creates a new status with the specified name and low priority - * - * @param name Name of the status - * @return A new status with the specified name and low priority - * @throws IllegalArgumentException If the name does not match the - * {@link #REGEX regex} - * @see #validateName(String) - */ - public static @NotNull SuccessStatus low(final @NotNull String name) throws IllegalArgumentException { - final String nameUpper = name.toUpperCase(Locale.ENGLISH); - - PluginStatus.validateName(nameUpper); - - return new SuccessStatus( - nameUpper, - Priority.LOW, - null - ); - } - - /** - * Creates a new status with the specified name, failure status, and low - * priority - * - * @param name Name of the status - * @param failureStatus The status that will be set if this status is not - * successful, or null if there is no failure status - * @return A new status with the given name and low priority - * @throws IllegalArgumentException If the name does not match the - * {@link #REGEX regex}, or if the failure - * status has a high priority - * @see #validateName(String) - * @see #validateFailureStatus(Priority, FailureStatus) - */ - @Contract("_, _ -> new") - public static @NotNull SuccessStatus low( - final @NotNull String name, - final @Nullable FailureStatus failureStatus - ) throws IllegalArgumentException { - final String nameUpper = name.toUpperCase(Locale.ENGLISH); - - PluginStatus.validateName(nameUpper); - PluginStatus.validateFailureStatus(Priority.LOW, failureStatus); - - return new SuccessStatus( - nameUpper, - Priority.LOW, - failureStatus - ); - } - - /** - * Creates a new status with the specified name and high priority - * - * @param name Name of the status - * @return A new status with the specified name and high priority - * @throws IllegalArgumentException If the name does not match the - * {@link #REGEX regex} - * @see #validateName(String) - */ - public static @NotNull SuccessStatus high(final @NotNull String name) throws IllegalArgumentException { - final String nameUpper = name.toUpperCase(Locale.ENGLISH); - - PluginStatus.validateName(nameUpper); - - return new SuccessStatus( - nameUpper, - Priority.HIGH, - null - ); - } - - /** - * Creates a new status with the specified name, failure status, and high - * priority - * - * @param name Name of the status - * @param failureStatus The status that will be set if this status is not - * successful, or null if there is no failure status - * @return A new status with the specified name, failure status, and high - * priority - * @throws IllegalArgumentException If the name does not match the - * {@link #REGEX regex}, or if the failure - * status has a low priority - * @see #validateName(String) - * @see #validateFailureStatus(Priority, FailureStatus) - */ - @Contract("_, _ -> new") - public static @NotNull SuccessStatus high( - final @NotNull String name, - final @Nullable FailureStatus failureStatus - ) throws IllegalArgumentException { - final String nameUpper = name.toUpperCase(Locale.ENGLISH); - - PluginStatus.validateName(nameUpper); - PluginStatus.validateFailureStatus(Priority.HIGH, failureStatus); - - return new SuccessStatus( - nameUpper, - Priority.HIGH, - failureStatus - ); - } - - /** - * @return The failure status, or null if there is no failure status present - */ - public @Nullable FailureStatus getFailureStatus() { - return this.failureStatus; - } - - @Override - public int hashCode() { - return this.failureStatus == null - ? super.hashCode() - : 31 * super.hashCode() + this.failureStatus.hashCode(); - } -} diff --git a/src/main/java/com/minersstudios/mscore/resource/ResourceManager.java b/src/main/java/com/minersstudios/mscore/resource/ResourceManager.java new file mode 100644 index 00000000..e9116e79 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/resource/ResourceManager.java @@ -0,0 +1,24 @@ +package com.minersstudios.mscore.resource; + +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.io.InputStream; + +public interface ResourceManager { + + /** + * Opens and returns the input stream of the resource + * + * @return The input stream of the resource + */ + @NotNull InputStream openStream() throws IOException; + + /** + * Returns the string representation of this resource manager + * + * @return The string representation of this resource manager + */ + @Override + @NotNull String toString(); +} diff --git a/src/main/java/com/minersstudios/mscore/resource/file/AbstractFileResourceManager.java b/src/main/java/com/minersstudios/mscore/resource/file/AbstractFileResourceManager.java new file mode 100644 index 00000000..3f1ebd2f --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/resource/file/AbstractFileResourceManager.java @@ -0,0 +1,30 @@ +package com.minersstudios.mscore.resource.file; + +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +public abstract class AbstractFileResourceManager implements FileResourceManager { + protected final File file; + + protected AbstractFileResourceManager(final @NotNull File file) { + this.file = file; + } + + @Override + public @NotNull File getFile() { + return this.file; + } + + @Override + public @NotNull FileInputStream openStream() throws IOException { + return new FileInputStream(this.file); + } + + @Override + public @NotNull String toString() { + return this.getClass().getSimpleName() + "{file=" + this.file + '}'; + } +} diff --git a/src/main/java/com/minersstudios/mscore/resource/file/FileResourceManager.java b/src/main/java/com/minersstudios/mscore/resource/file/FileResourceManager.java new file mode 100644 index 00000000..6bf0116d --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/resource/file/FileResourceManager.java @@ -0,0 +1,16 @@ +package com.minersstudios.mscore.resource.file; + +import com.minersstudios.mscore.resource.ResourceManager; +import org.jetbrains.annotations.NotNull; + +import java.io.File; + +public interface FileResourceManager extends ResourceManager { + + /** + * Returns the file of the resource + * + * @return The file of the resource + */ + @NotNull File getFile(); +} diff --git a/src/main/java/com/minersstudios/mscore/resource/github/AbstractGithubResourceManager.java b/src/main/java/com/minersstudios/mscore/resource/github/AbstractGithubResourceManager.java new file mode 100644 index 00000000..849935af --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/resource/github/AbstractGithubResourceManager.java @@ -0,0 +1,217 @@ +package com.minersstudios.mscore.resource.github; + +import com.google.gson.Gson; +import com.minersstudios.mscore.plugin.MSLogger; +import com.minersstudios.mscore.resource.file.AbstractFileResourceManager; +import com.minersstudios.mscore.utility.ChatUtils; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicReference; + +import static java.net.HttpURLConnection.*; + +public abstract class AbstractGithubResourceManager extends AbstractFileResourceManager implements GithubResourceManager { + protected final String user; + protected final String repo; + protected final AtomicReference tags; + protected final String currentTag; + private transient final String token; + + private static final Gson GSON = new Gson(); + private static final String AUTHORIZATION_HEADER = "Authorization"; + private static final String AUTHORIZATION_VALUE = "Bearer %s"; + + protected AbstractGithubResourceManager( + final @NotNull File file, + final @NotNull String user, + final @NotNull String repo, + final @Nullable String currentTag, + final @Nullable String token + ) { + super(file); + + this.user = user; + this.repo = repo; + this.tags = new AtomicReference<>(null); + this.currentTag = currentTag; + this.token = token; + } + + @Override + public @NotNull String getUser() { + return this.user; + } + + @Override + public @NotNull String getRepo() { + return this.repo; + } + + @Override + public @NotNull CompletableFuture getLatestTag() { + return this.getTags() + .thenApplyAsync(tags -> { + if (tags.length == 0) { + throw new IllegalStateException("Provided repository has no tags"); + } + + return tags[0]; + }); + } + + @Override + public @NotNull CompletableFuture getTags() { + final Tag[] tags = this.getTagsNow(); + + return tags != null + && tags.length != 0 + ? CompletableFuture.completedFuture(tags) + : this.updateTags(); + } + + @Override + public @Nullable Tag getLatestTagNow() { + final Tag[] tags = this.getTagsNow(); + + return tags != null + && tags.length != 0 + ? tags[0] + : null; + } + + @Override + public Tag @Nullable [] getTagsNow() { + return this.tags.get(); + } + + @Override + public @NotNull CompletableFuture getUri() { + return this.getLatestTag() + .thenApplyAsync(tag -> { + final String tagName = tag.getName(); + + if (ChatUtils.isBlank(tagName)) { + throw new IllegalStateException("For some reason, the latest tag has no name"); + } + + return this.getFileUri(tagName); + }); + } + + @Contract(" -> new") + @Override + public @NotNull URI getTagsUri() { + return URI.create(TAGS_URL_FORMAT.formatted(this.user, this.repo)); + } + + @Override + public @NotNull String toString() { + return this.getClass().getSimpleName() + '{' + + "file=" + this.getFile() + + ", user=" + this.user + + ", repo=" + this.repo + + ", tags=" + Arrays.toString(this.getTagsNow()) + + '}'; + } + + @Override + public @NotNull CompletableFuture updateFile(final boolean force) { + return force + ? this.getUri() + .thenApplyAsync( + uri -> { + final File directory = this.file.getParentFile(); + + if ( + !directory.exists() + && !directory.mkdirs() + ) { + MSLogger.warning("Failed to create a new directory: " + directory.getAbsolutePath()); + } + + final Path path = this.file.toPath(); + final HttpClient client = + HttpClient.newBuilder() + .followRedirects(HttpClient.Redirect.ALWAYS) + .build(); + + try { + final int statusCode = + client.send( + HttpRequest.newBuilder(uri).build(), + HttpResponse.BodyHandlers.ofFile(path) + ).statusCode(); + + if (statusCode != HTTP_OK) { + throw new IllegalStateException( + "Failed to update file: " + this.file + " (status code: " + statusCode + ')' + ); + } + } catch (final IOException | InterruptedException e) { + throw new IllegalStateException("Failed to update file: " + this.file, e); + } + + return this.file; + } + ) + : this.getLatestTag() + .thenCompose( + tag -> tag.getName().equals(this.currentTag) && this.file.exists() + ? CompletableFuture.completedFuture(this.file) + : this.updateFile(true) + ); + } + + protected @NotNull CompletableFuture updateTags() { + return CompletableFuture.supplyAsync(() -> { + final HttpRequest.Builder builder = HttpRequest.newBuilder(this.getTagsUri()).GET(); + final HttpResponse response; + + if (ChatUtils.isNotBlank(this.token)) { + builder.setHeader( + AUTHORIZATION_HEADER, + AUTHORIZATION_VALUE.formatted(this.token) + ); + } + + try { + response = HttpClient.newHttpClient().send( + builder.build(), + HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8) + ); + } catch (final IOException | InterruptedException e) { + throw new IllegalStateException("Failed to get latest tag for " + this.user + '/' + this.repo, e); + } + + final int statusCode = response.statusCode(); + + switch (statusCode) { + case HTTP_OK -> { + final Tag[] newTags = GSON.fromJson(response.body(), Tag[].class); + + this.tags.set(newTags); + + return newTags; + } + case HTTP_FORBIDDEN -> throw new IllegalStateException("GitHub API rate limit exceeded"); + case HTTP_NOT_FOUND -> throw new IllegalStateException("GitHub repository not found"); + default -> throw new IllegalStateException( + "Failed to get latest tag for " + this.user + '/' + this.repo + + "(Status code: " + statusCode + ')' + ); + } + }); + } +} diff --git a/src/main/java/com/minersstudios/mscore/resource/github/GithubResourceManager.java b/src/main/java/com/minersstudios/mscore/resource/github/GithubResourceManager.java new file mode 100644 index 00000000..06897843 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/resource/github/GithubResourceManager.java @@ -0,0 +1,107 @@ +package com.minersstudios.mscore.resource.github; + +import com.minersstudios.mscore.resource.file.FileResourceManager; +import com.minersstudios.mscore.resource.uri.URIResourceManager; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.net.URI; +import java.util.concurrent.CompletableFuture; + +public interface GithubResourceManager extends FileResourceManager, URIResourceManager { + /** + * The URL to get the tags of a GitHub repository. + *
+ * Arguments: + *
    + *
  1. GitHub user
  2. + *
  3. GitHub repository
  4. + *
+ */ + String TAGS_URL_FORMAT = "https://api.github.com/repos/%s/%s/tags"; + + /** + * Returns the GitHub user + * + * @return The GitHub user + */ + @NotNull String getUser(); + + /** + * Returns the GitHub repository + * + * @return The GitHub repository + */ + @NotNull String getRepo(); + + /** + * Returns a future containing the latest tag of the repository. + *
+ * Returns failed future with {@link IllegalStateException}, if the + * repository has no tags. + * + * @return A future containing the latest tag of the repository + */ + @NotNull CompletableFuture getLatestTag(); + + /** + * Returns future and sets the tag array of the repository + * + * @return A future containing the tag array of the repository + */ + @NotNull CompletableFuture getTags(); + + /** + * Returns the latest tag of the repository + * + * @return The latest tag of the repository + */ + @Nullable Tag getLatestTagNow(); + + /** + * Returns the tag array of the repository + * + * @return The tag array of the repository + */ + Tag @Nullable [] getTagsNow(); + + /** + * Generates and returns a new URI from the user, repo, latest tag and file + * name fields. + *
+ * Returns failed future with {@link IllegalStateException}, if the latest + * tag has no name, or if the repository has no tags. + * + * @return The future containing the URI of the resource pack file + */ + @Override + @NotNull CompletableFuture getUri(); + + /** + * Returns the repository tags URI + * + * @return The repository tags URI + */ + @Contract(" -> new") + @NotNull URI getTagsUri(); + + /** + * Returns the URI of the file for the given tag + * + * @param tag The tag name + * @return The URI of the file + */ + @Contract("_ -> new") + @NotNull URI getFileUri(final @NotNull String tag); + + /** + * Updates and returns the future containing the file + * + * @param forceUpdate If the file should be updated even if the current tag + * is the latest + * @return The future containing the file + */ + @NotNull CompletableFuture updateFile(final boolean forceUpdate); +} diff --git a/src/main/java/com/minersstudios/msessentials/resourcepack/resource/Tag.java b/src/main/java/com/minersstudios/mscore/resource/github/Tag.java similarity index 99% rename from src/main/java/com/minersstudios/msessentials/resourcepack/resource/Tag.java rename to src/main/java/com/minersstudios/mscore/resource/github/Tag.java index 8a6eb548..b74d4f24 100644 --- a/src/main/java/com/minersstudios/msessentials/resourcepack/resource/Tag.java +++ b/src/main/java/com/minersstudios/mscore/resource/github/Tag.java @@ -1,4 +1,4 @@ -package com.minersstudios.msessentials.resourcepack.resource; +package com.minersstudios.mscore.resource.github; import com.google.gson.annotations.SerializedName; import org.jetbrains.annotations.Contract; diff --git a/src/main/java/com/minersstudios/mscore/resource/uri/AbstractURIResourceManager.java b/src/main/java/com/minersstudios/mscore/resource/uri/AbstractURIResourceManager.java new file mode 100644 index 00000000..cfa74825 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/resource/uri/AbstractURIResourceManager.java @@ -0,0 +1,31 @@ +package com.minersstudios.mscore.resource.uri; + +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.util.concurrent.CompletableFuture; + +public abstract class AbstractURIResourceManager implements URIResourceManager { + protected final URI uri; + + protected AbstractURIResourceManager(final @NotNull URI uri) { + this.uri = uri; + } + + @Override + public @NotNull CompletableFuture getUri() { + return CompletableFuture.completedFuture(this.uri); + } + + @Override + public @NotNull InputStream openStream() throws IOException { + return this.uri.toURL().openStream(); + } + + @Override + public @NotNull String toString() { + return this.getClass().getSimpleName() + "{uri=" + this.uri + '}'; + } +} diff --git a/src/main/java/com/minersstudios/mscore/resource/uri/URIResourceManager.java b/src/main/java/com/minersstudios/mscore/resource/uri/URIResourceManager.java new file mode 100644 index 00000000..ff425be8 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/resource/uri/URIResourceManager.java @@ -0,0 +1,17 @@ +package com.minersstudios.mscore.resource.uri; + +import com.minersstudios.mscore.resource.ResourceManager; +import org.jetbrains.annotations.NotNull; + +import java.net.URI; +import java.util.concurrent.CompletableFuture; + +public interface URIResourceManager extends ResourceManager { + + /** + * Returns the URI of the resource + * + * @return The future containing the URI of the resource + */ + @NotNull CompletableFuture getUri(); +} diff --git a/src/main/java/com/minersstudios/mscore/status/FailureStatus.java b/src/main/java/com/minersstudios/mscore/status/FailureStatus.java new file mode 100644 index 00000000..eba4ecfc --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/status/FailureStatus.java @@ -0,0 +1,50 @@ +package com.minersstudios.mscore.status; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.annotation.concurrent.Immutable; +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * Represents a failure status. + *
+ * Factory methods for creating a failure status: + *
    + *
  • {@link #failure(String, Priority)}
  • + *
  • {@link #failureLow(String)}
  • + *
  • {@link #failureHigh(String)}
  • + *
+ * + * @see Status + */ +@Immutable +public class FailureStatus extends ImplStatus { + + protected FailureStatus( + final @StatusKey @NotNull String key, + final @NotNull Priority priority + ) { + super(key, priority); + } + + @ApiStatus.OverrideOnly + @Override + public void accept( + final @Nullable Consumer onSuccess, + final @NotNull Consumer onFailure + ) { + onFailure.accept(this); + } + + @ApiStatus.OverrideOnly + @Override + public @NotNull U apply( + final @Nullable Function onSuccess, + final @NotNull Function onFailure + ) { + return onFailure.apply(this); + } +} diff --git a/src/main/java/com/minersstudios/mscore/status/ImplStatus.java b/src/main/java/com/minersstudios/mscore/status/ImplStatus.java new file mode 100644 index 00000000..4bafb926 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/status/ImplStatus.java @@ -0,0 +1,96 @@ +package com.minersstudios.mscore.status; + +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.annotation.concurrent.Immutable; +import java.util.function.Consumer; +import java.util.function.Function; + +@Immutable +abstract class ImplStatus implements Status { + private final String key; + private final Status.Priority priority; + + protected ImplStatus( + final @StatusKey @NotNull String key, + final @NotNull Priority priority + ) { + this.key = key; + this.priority = priority; + } + + @StatusKey + @Override + public final @NotNull String getKey() { + return this.key; + } + + @Override + public final @NotNull Priority getPriority() { + return this.priority; + } + + @Override + public final boolean isHighPriority() { + return this.priority == Priority.HIGH; + } + + @Override + public final boolean isLowPriority() { + return this.priority == Priority.LOW; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + + result = prime * result + this.key.hashCode(); + result = prime * result + this.priority.hashCode(); + + return result; + } + + @Contract("null -> false") + @Override + public boolean equals(final @Nullable Object obj) { + if (this == obj) { + return true; + } + + if ( + obj == null + || this.getClass() != obj.getClass() + ) { + return false; + } + + final ImplStatus that = (ImplStatus) obj; + + return this.key.equals(that.key) + && this.priority == that.priority; + } + + @Override + public @NotNull String toString() { + return this.key + '{' + this.priority + '}'; + } + + @Override + public void accept( + final @NotNull Consumer onSuccess, + final @NotNull Consumer onFailure + ) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Provided status is not supported"); + } + + @Override + public U apply( + final Function onSuccess, + final Function onFailure + ) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Provided status is not supported"); + } +} diff --git a/src/main/java/com/minersstudios/mscore/status/Status.java b/src/main/java/com/minersstudios/mscore/status/Status.java new file mode 100644 index 00000000..38baae21 --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/status/Status.java @@ -0,0 +1,291 @@ +package com.minersstudios.mscore.status; + +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Consumer; +import java.util.function.Function; + +import static com.minersstudios.mscore.status.StatusKey.Validator.validate; + +/** + * Represents a status. + *
+ * There are two types of statuses: + *
    + *
  • {@link SuccessStatus Success Status}
  • + *
  • {@link FailureStatus Failure Status}
  • + *
+ */ +public interface Status { + + /** + * Returns the key of the status + * + * @return The key of the status + */ + @StatusKey + @NotNull String getKey(); + + /** + * Returns the priority of the status + * + * @return The priority of the status + */ + @NotNull Priority getPriority(); + + /** + * Returns whether the status is a high priority + * + * @return True if the status is a high priority + */ + boolean isHighPriority(); + + /** + * Returns whether the status is a low priority + * + * @return True if the status is a low priority + */ + boolean isLowPriority(); + + /** + * Returns the hash code of the status + * + * @return Hash code of the status + */ + @Override + int hashCode(); + + /** + * Returns whether the object is equal to this status + * + * @param obj The object to compare + * @return True if the object is equal to this status + */ + @Contract("null -> false") + @Override + boolean equals(final @Nullable Object obj); + + /** + * Returns a string representation of the status + * + * @return A string representation of the status + */ + @Override + @NotNull String toString(); + + /** + * Accepts the consumer to this status + * + * @param onSuccess Consumer for the success status + * @param onFailure Consumer for the failure status + * @throws UnsupportedOperationException If the status is not supported + */ + void accept( + final Consumer onSuccess, + final Consumer onFailure + ) throws UnsupportedOperationException; + + /** + * Applies the function to this status + * + * @param onSuccess Function for the success status + * @param onFailure Function for the failure status + * @param The type of the result + * @return The result of the function + * @throws UnsupportedOperationException If the status is not supported + */ + U apply( + final Function onSuccess, + final Function onFailure + ) throws UnsupportedOperationException; + + /** + * Creates a new status with the specified key and low priority + * + * @param key Key of the status + * @return A new status with the specified key and low priority + * @throws IllegalArgumentException If the key does not match the + * {@link StatusKey#REGEX regex} + * @see #success(String, Priority) + */ + @Contract("_ -> new") + static @NotNull SuccessStatus successLow(final @StatusKey @NotNull String key) throws IllegalArgumentException { + return success(key, Priority.LOW); + } + + /** + * Creates a new status with the specified key, failure status, and low + * priority + * + * @param key Key of the status + * @param failureStatus The status that will be set if this status is not + * successful, or null if there is no failure status + * @return A new status with the given key and low priority + * @throws IllegalArgumentException If the key does not match the + * {@link StatusKey#REGEX regex} + * @throws IllegalStateException If the failure status has a different + * priority than the specified priority + * @see #success(String, Priority, FailureStatus) + */ + @Contract("_, _ -> new") + static @NotNull SuccessStatus successLow( + final @StatusKey @NotNull String key, + final @Nullable FailureStatus failureStatus + ) throws IllegalArgumentException, IllegalStateException { + return success(key, Priority.LOW, failureStatus); + } + + /** + * Creates a new status with the specified key and high priority + * + * @param key Key of the status + * @return A new status with the specified key and high priority + * @throws IllegalArgumentException If the key does not match the + * {@link StatusKey#REGEX regex} + * @see #success(String, Priority) + */ + @Contract("_ -> new") + static @NotNull SuccessStatus successHigh(final @StatusKey @NotNull String key) throws IllegalArgumentException { + return success(key, Priority.HIGH); + } + + /** + * Creates a new status with the specified key, failure status, and high + * priority + * + * @param key Key of the status + * @param failureStatus The status that will be set if this status is not + * successful, or null if there is no failure status + * @return A new status with the specified key, failure status, and high + * priority + * @throws IllegalArgumentException If the key does not match the + * {@link StatusKey#REGEX regex} + * @throws IllegalStateException If the failure status has a different + * priority than the specified priority + * @see #success(String, Priority, FailureStatus) + */ + @Contract("_, _ -> new") + static @NotNull SuccessStatus successHigh( + final @StatusKey @NotNull String key, + final @Nullable FailureStatus failureStatus + ) throws IllegalArgumentException, IllegalStateException { + return success(key, Priority.HIGH, failureStatus); + } + + /** + * Creates a new status with the specified key and priority + * + * @param key Key of the status + * @param priority Priority of the status + * @return A new status with the specified key and priority + * @throws IllegalArgumentException If the key does not match the + * {@link StatusKey#REGEX regex} + * @see StatusKey.Validator#validate(String) + */ + @Contract("_, _ -> new") + static @NotNull SuccessStatus success( + final @StatusKey @NotNull String key, + final @NotNull Priority priority + ) throws IllegalArgumentException { + validate(key); + + return new SuccessStatus(key, priority, null); + } + + /** + * Creates a new status with the specified key, priority, and failure status + * + * @param key Key of the status + * @param priority Priority of the status + * @param failureStatus The status that will be set if this status is not + * successful, or null if there is no failure status + * @return A new status with the specified key, priority, and failure status + * @throws IllegalArgumentException If the key does not match the + * {@link StatusKey#REGEX regex} + * @throws IllegalStateException If the failure status has a different + * priority than the specified priority + * @see StatusKey.Validator#validate(String) + */ + @Contract("_, _, _ -> new") + static @NotNull SuccessStatus success( + final @StatusKey @NotNull String key, + final @NotNull Priority priority, + final @Nullable FailureStatus failureStatus + ) throws IllegalArgumentException, IllegalStateException { + validate(key); + + if ( + failureStatus != null + && failureStatus.getPriority() != priority + ) { + throw new IllegalArgumentException( + "Failure status must have the same priority as the main status" + ); + } + + return new SuccessStatus(key, priority, failureStatus); + } + + /** + * Creates a new status failure with the specified key and low priority + * + * @param key Key of the failure status + * @return A new failure status with the specified key and low priority + * @throws IllegalArgumentException If the key does not match the + * {@link StatusKey#REGEX regex} + * @see #failure(String, Priority) + */ + @Contract("_ -> new") + static @NotNull FailureStatus failureLow(final @StatusKey @NotNull String key) throws IllegalArgumentException { + return failure(key, Priority.LOW); + } + + /** + * Creates a new status failure with the specified key and medium priority + * + * @param key Key of the failure status + * @return A new failure status with the specified key and medium priority + * @throws IllegalArgumentException If the key does not match the + * {@link StatusKey#REGEX regex} + * @see #failure(String, Priority) + */ + @Contract("_ -> new") + static @NotNull FailureStatus failureHigh(final @StatusKey @NotNull String key) throws IllegalArgumentException { + return failure(key, Priority.HIGH); + } + + /** + * Creates a new status failure with the specified key and priority + * + * @param key Key of the failure status + * @param priority Priority of the failure status + * @return A new failure status with the specified key and priority + * @throws IllegalArgumentException If the key does not match the + * {@link StatusKey#REGEX regex} + * @see StatusKey.Validator#validate(String) + */ + @Contract("_, _ -> new") + static @NotNull FailureStatus failure( + final @StatusKey @NotNull String key, + final @NotNull Priority priority + ) throws IllegalArgumentException { + validate(key); + + return new FailureStatus(key, priority); + } + + /** + * Priority of the status. + *
+ * There are two types of priorities: + *
    + *
  • {@link Priority#LOW Low-priority}
  • + *
  • {@link Priority#HIGH High-priority}
  • + *
+ */ + enum Priority { + LOW, HIGH + } +} diff --git a/src/main/java/com/minersstudios/mscore/plugin/status/StatusHandler.java b/src/main/java/com/minersstudios/mscore/status/StatusHandler.java similarity index 71% rename from src/main/java/com/minersstudios/mscore/plugin/status/StatusHandler.java rename to src/main/java/com/minersstudios/mscore/status/StatusHandler.java index 719c56e7..38955191 100644 --- a/src/main/java/com/minersstudios/mscore/plugin/status/StatusHandler.java +++ b/src/main/java/com/minersstudios/mscore/status/StatusHandler.java @@ -1,11 +1,11 @@ -package com.minersstudios.mscore.plugin.status; +package com.minersstudios.mscore.status; import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Unmodifiable; +import org.jetbrains.annotations.UnmodifiableView; +import javax.annotation.concurrent.ThreadSafe; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -15,14 +15,15 @@ import java.util.concurrent.atomic.AtomicReference; /** - * Handles plugin statuses and runs registered watchers when a status is set + * Handles statuses and runs registered watchers when a status is set * - * @see PluginStatus + * @see Status * @see StatusWatcher */ +@ThreadSafe public final class StatusHandler { - private final AtomicReference highStatus; - private final Set lowStatusSet; + private final AtomicReference highStatus; + private final Set lowStatusSet; private final List watcherList; /** @@ -35,74 +36,42 @@ public StatusHandler() { } /** - * @return An unmodifiable set of all low-priority statuses + * Returns the high-priority status + * + * @return An optional containing the high-priority status if present, + * otherwise an empty optional */ - public @NotNull @Unmodifiable Set lowStatusSet() { - return Collections.unmodifiableSet(this.lowStatusSet); + public @NotNull Optional getHighStatus() { + return Optional.ofNullable(this.highStatus.get()); } /** - * @return An unmodifiable set of all statuses + * Returns an unmodifiable set view of all high-priority statuses + * + * @return An unmodifiable set view of all high-priority statuses */ - public @NotNull @Unmodifiable Set statusSet() { - final var set = new ObjectOpenHashSet<>(this.lowStatusSet); - final PluginStatus highStatus = this.highStatus.get(); - - if (highStatus != null) { - set.add(highStatus); - } - - return Collections.unmodifiableSet(set); + public @NotNull @UnmodifiableView Set lowStatusSet() { + return Collections.unmodifiableSet(this.lowStatusSet); } /** - * @return An unmodifiable watcher list + * Returns an unmodifiable view of the watcher list + * + * @return An unmodifiable view of the watcher list */ - public @NotNull @Unmodifiable List watcherList() { + public @NotNull @UnmodifiableView List watcherList() { return Collections.unmodifiableList(this.watcherList); } /** - * @return An optional containing the high-priority status if present, - * otherwise an empty optional - */ - public @NotNull Optional getHighStatus() { - return Optional.ofNullable(this.highStatus.get()); - } - - /** - * Sets the specified status and runs all the registered watchers with - * this status + * Gets all the watchers that contain the specified status * - * @param status Status to be set - */ - public void setStatus(final @NotNull PluginStatus status) { - if (status.getPriority() == PluginStatus.Priority.HIGH) { - this.highStatus.set(status); - } else { - this.lowStatusSet.add(status); - } - - if (!this.watcherList.isEmpty()) { - final var completed = new ObjectArrayList(); - - for (final var watcher : this.watcherList) { - if (watcher.tryRun(status)) { - completed.add(watcher); - } - } - - this.watcherList.removeAll(completed); - } - } - - /** * @param status Status to be checked * @return A new list of watchers that contain the specified status * @throws UnsupportedOperationException If the status type is not supported */ @Contract("_ -> new") - public @NotNull List getWatchers(final @NotNull PluginStatus status) throws UnsupportedOperationException { + public @NotNull List getWatchers(final @NotNull Status status) throws UnsupportedOperationException { final var list = new ObjectArrayList(); for (final var watcher : this.watcherList) { @@ -140,38 +109,34 @@ public void removeWatcher(final @NotNull StatusWatcher watcher) { } /** - * @param status Status to be checked - * @return True if the status is present, false otherwise - */ - public boolean contains(final @NotNull PluginStatus status) { - return status.isHighPriority() - ? status.equals(this.highStatus.get()) - : this.lowStatusSet.contains(status); - } - - /** - * @param first First status to be checked - * @param rest Rest of the statuses to be checked - * @return True if any of the statuses is present, false otherwise + * Assigns the specified status and runs all the registered watchers with + * this status + * + * @param status Status to be assigned */ - public boolean containsAny( - final @NotNull PluginStatus first, - final PluginStatus @NotNull ... rest - ) { - if (this.contains(first)) { - return true; + public void assignStatus(final @NotNull Status status) { + if (status.getPriority() == Status.Priority.HIGH) { + this.highStatus.set(status); + } else { + this.lowStatusSet.add(status); } - for (final var status : rest) { - if (this.contains(status)) { - return true; + if (!this.watcherList.isEmpty()) { + final var completed = new ObjectArrayList(); + + for (final var watcher : this.watcherList) { + if (watcher.tryRun(status)) { + completed.add(watcher); + } } - } - return false; + this.watcherList.removeAll(completed); + } } /** + * Returns whether all the specified statuses are present + * * @param first First status to be checked * @param rest Rest of the statuses to be checked * @return True if all the statuses are present, false otherwise @@ -179,10 +144,10 @@ public boolean containsAny( * statuses specified */ public boolean containsAll( - final @NotNull PluginStatus first, - final PluginStatus @NotNull ... rest + final @NotNull Status first, + final Status @NotNull ... rest ) throws IllegalArgumentException { - final PluginStatus highStatus = this.highStatus.get(); + final Status highStatus = this.highStatus.get(); boolean hasHighPriority = first.isHighPriority(); if ( @@ -210,4 +175,40 @@ public boolean containsAll( return true; } + + /** + * Returns whether any of the specified statuses are present + * + * @param first First status to be checked + * @param rest Rest of the statuses to be checked + * @return True if any of the statuses is present, false otherwise + */ + public boolean containsAny( + final @NotNull Status first, + final Status @NotNull ... rest + ) { + if (this.contains(first)) { + return true; + } + + for (final var status : rest) { + if (this.contains(status)) { + return true; + } + } + + return false; + } + + /** + * Returns whether the specified status is present + * + * @param status Status to be checked + * @return True if the status is present, false otherwise + */ + public boolean contains(final @NotNull Status status) { + return status.isHighPriority() + ? status.equals(this.highStatus.get()) + : this.lowStatusSet.contains(status); + } } diff --git a/src/main/java/com/minersstudios/mscore/status/StatusKey.java b/src/main/java/com/minersstudios/mscore/status/StatusKey.java new file mode 100644 index 00000000..8cc55aec --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/status/StatusKey.java @@ -0,0 +1,73 @@ +package com.minersstudios.mscore.status; + +import org.intellij.lang.annotations.RegExp; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + +import java.lang.annotation.*; +import java.util.regex.Pattern; + +import static java.lang.annotation.ElementType.*; + +/** + * Annotation used to mark the key of the status. + *
+ * The status key must match the {@link #REGEX regex} pattern. + * + * @see StatusKey.Validator + */ +@Documented +@Retention(RetentionPolicy.CLASS) +@Target({ + FIELD, + LOCAL_VARIABLE, + METHOD, + PARAMETER +}) +@org.intellij.lang.annotations.Pattern(StatusKey.REGEX) +public @interface StatusKey { + /** The regex pattern that a valid status key must match */ + @RegExp String REGEX = "^[A-Z][A-Z0-9_]*$"; + + /** The compiled Pattern of the {@link #REGEX regex} string */ + Pattern PATTERN = Pattern.compile(REGEX); + + /** + * Validator class for the {@link StatusKey} annotation to check whether the + * key of the status matches the {@link #REGEX regex} + * + * @see #matches(String) + * @see #validate(String) + */ + final class Validator { + + @Contract(" -> fail") + private Validator() throws AssertionError { + throw new AssertionError("Utility class"); + } + + /** + * Checks whether the key of the status matches the {@link #REGEX regex} + * + * @param key Key of the status + * @return Whether the key matches the {@link #REGEX regex} + */ + public static boolean matches(final @StatusKey @NotNull String key) { + return PATTERN.matcher(key).matches(); + } + + /** + * Validates the key of the status + * + * @param key Key of the status + * @throws IllegalArgumentException If the key does not match the + * {@link #REGEX regex} + * @see #matches(String) + */ + public static void validate(final @StatusKey @NotNull String key) throws IllegalArgumentException { + if (!matches(key)) { + throw new IllegalArgumentException("Key must match regex: " + REGEX); + } + } + } +} diff --git a/src/main/java/com/minersstudios/mscore/plugin/status/StatusWatcher.java b/src/main/java/com/minersstudios/mscore/status/StatusWatcher.java similarity index 52% rename from src/main/java/com/minersstudios/mscore/plugin/status/StatusWatcher.java rename to src/main/java/com/minersstudios/mscore/status/StatusWatcher.java index 98a1b010..656f26de 100644 --- a/src/main/java/com/minersstudios/mscore/plugin/status/StatusWatcher.java +++ b/src/main/java/com/minersstudios/mscore/status/StatusWatcher.java @@ -1,12 +1,29 @@ -package com.minersstudios.mscore.plugin.status; +package com.minersstudios.mscore.status; import com.google.common.base.Joiner; +import com.google.common.collect.Sets; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import org.jetbrains.annotations.*; -import java.util.*; - -public class StatusWatcher { +import javax.annotation.concurrent.ThreadSafe; +import java.util.Arrays; +import java.util.Collections; +import java.util.Objects; +import java.util.Set; + +/** + * Status watcher for handling statuses. + *
+ * The watcher will run the status runnables when all statuses have been + * triggered successfully, or if {@link #isAnySuccess()}/{@link #isAnyFailure()} + * is true, when any of the statuses have been triggered successfully. + *
+ * You can use the {@link #builder()} to create a new watcher. + * + * @see StatusHandler + */ +@ThreadSafe +public final class StatusWatcher { private final Set successStatusSet; private final Set failureStatusSet; private final Runnable successRunnable; @@ -14,11 +31,15 @@ public class StatusWatcher { private final boolean isAnySuccess; private final boolean isAnyFailure; - /** - * Constructs a new watcher with the specified builder - * - * @param builder Builder to be used - */ + private static final String FORMAT = "%s{" + + "successStatusSet=[%s], " + + "failureStatusSet=[%s], " + + "successRunnable=%s, " + + "failureRunnable=%s, " + + "isAnySuccess=%s, " + + "isAnyFailure=%s" + + '}'; + private StatusWatcher(final @NotNull Builder builder) { this.successStatusSet = builder.successStatusSet; this.failureStatusSet = builder.failureStatusSet; @@ -29,30 +50,35 @@ private StatusWatcher(final @NotNull Builder builder) { } /** - * Creates a new watcher builder + * Returns an unmodifiable set view of all statuses * - * @return A new builder + * @return An unmodifiable set view of all statuses */ - @Contract(" -> new") - public static @NotNull Builder builder() { - return new Builder(); + public @NotNull @UnmodifiableView Set statuses() { + return Sets.union(this.successStatusSet, this.failureStatusSet); } /** - * @return An unmodifiable set of success statuses + * Returns an unmodifiable set view of success statuses + * + * @return An unmodifiable set view of success statuses */ - public @NotNull @Unmodifiable Set successStatusSet() { + public @NotNull @UnmodifiableView Set successStatusSet() { return Collections.unmodifiableSet(this.successStatusSet); } /** - * @return An unmodifiable set of failure statuses + * Returns an unmodifiable set view of failure statuses + * + * @return An unmodifiable set view of failure statuses */ - public @NotNull @Unmodifiable Set failureStatusSet() { + public @NotNull @UnmodifiableView Set failureStatusSet() { return Collections.unmodifiableSet(this.failureStatusSet); } /** + * Returns the success runnable + * * @return The success runnable */ public @Nullable Runnable getSuccessRunnable() { @@ -60,6 +86,8 @@ private StatusWatcher(final @NotNull Builder builder) { } /** + * Returns the failure runnable + * * @return The failure runnable */ public @Nullable Runnable getFailureRunnable() { @@ -67,37 +95,45 @@ private StatusWatcher(final @NotNull Builder builder) { } /** - * @return Whether any success status will trigger the success-runnable, - * even if there are other success statuses that have not been - * triggered yet. Otherwise, the success-runnable will only be - * triggered if all success statuses have been triggered - * successfully. + * Returns whether any success status will trigger the success-runnable, + * even if there are other success statuses that have not been triggered + * yet. + *
+ * Otherwise, the success-runnable will only be triggered if all success + * statuses have been triggered successfully. + * + * @return Whether any success status will trigger the success-runnable */ public boolean isAnySuccess() { return this.isAnySuccess; } /** - * @return Whether any failure status will trigger the failure-runnable, - * even if there are other failure statuses that have not been - * triggered yet. Otherwise, the failure-runnable will only be - * triggered if all failure statuses have been triggered - * successfully. + * Returns whether any failure status will trigger the failure-runnable, + * even if there are other failure statuses that have not been triggered + * yet. + *
+ * Otherwise, the failure-runnable will only be triggered if all failure + * statuses have been triggered successfully. + * + * @return Whether any failure status will trigger the failure-runnable */ public boolean isAnyFailure() { return this.isAnyFailure; } /** + * Returns whether all the specified statuses are present + * * @param first First status to be checked * @param rest Rest of the statuses to be checked * @return True if all the statuses are present, false otherwise - * @throws UnsupportedOperationException If the status type is not supported - * @see #contains(PluginStatus) + * @throws UnsupportedOperationException If the status is not supported + * @see #contains(Status) */ public boolean containsAll( - final @NotNull PluginStatus first, - final PluginStatus @NotNull ... rest + final @NotNull Status first, + final Status @NotNull ... rest ) throws UnsupportedOperationException { if (!this.contains(first)) { return false; @@ -113,15 +149,17 @@ public boolean containsAll( } /** + * Returns whether any of the specified statuses are present + * * @param first First status to be checked * @param rest Rest of the statuses to be checked * @return True if any of the statuses is present, false otherwise - * @throws UnsupportedOperationException If the status type is not supported - * @see #contains(PluginStatus) + * @throws UnsupportedOperationException If the status is not supported + * @see #contains(Status) */ public boolean containsAny( - final @NotNull PluginStatus first, - final PluginStatus @NotNull ... rest + final @NotNull Status first, + final Status @NotNull ... rest ) throws UnsupportedOperationException { if (this.contains(first)) { return true; @@ -137,37 +175,49 @@ public boolean containsAny( } /** + * Returns whether the specified status is present + * * @param status Status to be checked * @return True if the status is present, false otherwise - * @throws UnsupportedOperationException If the status type is not supported + * @throws UnsupportedOperationException If the status is not supported * @see #containsSuccess(SuccessStatus) * @see #containsFailure(FailureStatus) */ - public boolean contains(final @Nullable PluginStatus status) throws UnsupportedOperationException { - if (status == null) { + public boolean contains(final @Nullable Status status) throws UnsupportedOperationException { + return status != null + && status.apply( + this::containsSuccess, + this::containsFailure + ); + } + + /** + * Returns whether all the specified success statuses are present + * + * @param first First status to be checked + * @param rest Rest of the statuses to be checked + * @return True if all the statuses are present, false otherwise + */ + public boolean containsAllSuccess( + final @NotNull SuccessStatus first, + final SuccessStatus @NotNull ... rest + ) { + if (!this.containsSuccess(first)) { return false; } - if (status instanceof final SuccessStatus success) { - return this.containsSuccess(success); - } else if (status instanceof final FailureStatus failure) { - return this.containsFailure(failure); + for (final var status : rest) { + if (!this.containsSuccess(status)) { + return false; + } } - throw new UnsupportedOperationException("Unsupported status type: " + status.getClass().getName()); - } - - /** - * @param status Status to be checked - * @return True if the status is present, false otherwise - */ - @Contract("null -> false") - public boolean containsSuccess(final @Nullable SuccessStatus status) { - return status != null - && this.successStatusSet.contains(status); + return true; } /** + * Returns whether any of the specified success statuses are present + * * @param first First status to be checked * @param rest Rest of the statuses to be checked * @return True if any of the statuses is present, false otherwise @@ -190,20 +240,34 @@ public boolean containsAnySuccess( } /** + * Returns whether the specified success status is present + * + * @param status Status to be checked + * @return True if the status is present, false otherwise + */ + @Contract("null -> false") + public boolean containsSuccess(final @Nullable SuccessStatus status) { + return status != null + && this.successStatusSet.contains(status); + } + + /** + * Returns whether all the specified failure statuses are present + * * @param first First status to be checked * @param rest Rest of the statuses to be checked * @return True if all the statuses are present, false otherwise */ - public boolean containsAllSuccess( - final @NotNull SuccessStatus first, - final SuccessStatus @NotNull ... rest + public boolean containsAllFailure( + final @NotNull FailureStatus first, + final FailureStatus @NotNull ... rest ) { - if (!this.containsSuccess(first)) { + if (!this.containsFailure(first)) { return false; } for (final var status : rest) { - if (!this.containsSuccess(status)) { + if (!this.containsFailure(status)) { return false; } } @@ -212,15 +276,8 @@ public boolean containsAllSuccess( } /** - * @param status Status to be checked - * @return True if the status is present, false otherwise - */ - public boolean containsFailure(final @Nullable FailureStatus status) { - return status != null - && this.failureStatusSet.contains(status); - } - - /** + * Returns whether any of the specified failure statuses are present + * * @param first First status to be checked * @param rest Rest of the statuses to be checked * @return True if any of the statuses is present, false otherwise @@ -243,40 +300,31 @@ public boolean containsAnyFailure( } /** - * @param first First status to be checked - * @param rest Rest of the statuses to be checked - * @return True if all the statuses are present, false otherwise + * Returns whether the specified failure status is present + * + * @param status Status to be checked + * @return True if the status is present, false otherwise */ - public boolean containsAllFailure( - final @NotNull FailureStatus first, - final FailureStatus @NotNull ... rest - ) { - if (!this.containsFailure(first)) { - return false; - } - - for (final var status : rest) { - if (!this.containsFailure(status)) { - return false; - } - } - - return true; + public boolean containsFailure(final @Nullable FailureStatus status) { + return status != null + && this.failureStatusSet.contains(status); } /** + * Tries to run the runnable for the specified status + * * @param status Status to be checked * @return True if the status is present and the runnable was run, false * otherwise + * @throws UnsupportedOperationException If the status type is not supported + * @see #tryRunSuccess(SuccessStatus) + * @see #tryRunFailure(FailureStatus) */ - public boolean tryRun(final @NotNull PluginStatus status) { - if (status instanceof final SuccessStatus success) { - return this.tryRunSuccess(success); - } else if (status instanceof final FailureStatus failure) { - return this.tryRunFailure(failure); - } - - throw new UnsupportedOperationException("Unsupported status type: " + status.getClass().getName()); + public boolean tryRun(final @NotNull Status status) throws UnsupportedOperationException { + return status.apply( + this::tryRunSuccess, + this::tryRunFailure + ); } /** @@ -287,18 +335,21 @@ public boolean tryRun(final @NotNull PluginStatus status) { * @param status Status to be checked * @return True if the status is present and the success runnable was * run, false otherwise + * @see #runSuccessNow() */ public boolean tryRunSuccess(final @NotNull SuccessStatus status) { - if (this.successStatusSet.contains(status)) { - this.successStatusSet.remove(status); - - if ( - this.isAnySuccess - || this.successStatusSet.isEmpty() - ) { - this.runSuccessNow(); - - return true; + synchronized (this.successStatusSet) { + if (this.successStatusSet.contains(status)) { + this.successStatusSet.remove(status); + + if ( + this.isAnySuccess + || this.successStatusSet.isEmpty() + ) { + this.runSuccessNow(); + + return true; + } } } @@ -313,18 +364,21 @@ public boolean tryRunSuccess(final @NotNull SuccessStatus status) { * @param status Status to be checked * @return True if the status is present and the failure runnable was * run, false otherwise + * @see #runFailureNow() */ public boolean tryRunFailure(final @NotNull FailureStatus status) { - if (this.failureStatusSet.contains(status)) { - this.failureStatusSet.remove(status); - - if ( - this.isAnyFailure - || this.failureStatusSet.isEmpty() - ) { - this.runFailureNow(); - - return true; + synchronized (this.failureStatusSet) { + if (this.failureStatusSet.contains(status)) { + this.failureStatusSet.remove(status); + + if ( + this.isAnyFailure + || this.failureStatusSet.isEmpty() + ) { + this.runFailureNow(); + + return true; + } } } @@ -350,29 +404,39 @@ public void runFailureNow() { } /** + * Returns the hash code of the watcher + * * @return Hash code of the watcher */ @Override public int hashCode() { - return Objects.hash( - this.successStatusSet, - this.failureStatusSet, - this.successRunnable, - this.failureRunnable - ); + final int prime = 31; + int result = 1; + + result = prime * result + this.successStatusSet.hashCode(); + result = prime * result + this.failureStatusSet.hashCode(); + result = prime * result + (this.successRunnable == null ? 0 : this.successRunnable.hashCode()); + result = prime * result + (this.failureRunnable == null ? 0 : this.failureRunnable.hashCode()); + result = prime * result + Boolean.hashCode(this.isAnySuccess); + result = prime * result + Boolean.hashCode(this.isAnyFailure); + + return result; } /** + * Returns whether the specified object is equal to this watcher + * * @param obj The object to compare * @return True if the object is equal to this watcher */ + @Contract("null -> false") @Override public boolean equals(final @Nullable Object obj) { return obj == this || ( obj instanceof StatusWatcher that - && this.successStatusSet.equals(that.successStatusSet) - && this.failureStatusSet.equals(that.failureStatusSet) + && this.successStatusSet.containsAll(that.successStatusSet) + && this.failureStatusSet.containsAll(that.failureStatusSet) && Objects.equals(this.successRunnable, that.successRunnable) && Objects.equals(this.failureRunnable, that.failureRunnable) && this.isAnySuccess == that.isAnySuccess @@ -381,20 +445,36 @@ public boolean equals(final @Nullable Object obj) { } /** + * Returns a string representation of the watcher + * * @return A string representation of the watcher */ @Override public @NotNull String toString() { - return "Watcher{" + - "successStatusSet=[" + Joiner.on(", ").join(this.successStatusSet) + ']' + - ", failureStatusSet=[" + Joiner.on(", ").join(this.failureStatusSet) + ']' + - ", successRunnable=" + this.successRunnable + - ", failureRunnable=" + this.failureRunnable + - '}'; + return String.format( + FORMAT, + this.getClass().getSimpleName(), + Joiner.on(", ").join(this.successStatusSet), + Joiner.on(", ").join(this.failureStatusSet), + this.successRunnable, + this.failureRunnable, + this.isAnySuccess, + this.isAnyFailure + ); } /** - * Builder for {@link StatusWatcher} + * Creates a new watcher builder + * + * @return A new builder + */ + @Contract(" -> new") + public static @NotNull Builder builder() { + return new Builder(); + } + + /** + * Builder for {@code StatusWatcher} * * @see StatusWatcher * @see StatusWatcher#builder() @@ -413,51 +493,49 @@ private Builder() { } /** - * Builds a new watcher from the builder values + * Returns an unmodifiable set of statuses present in the builder * - * @return A new watcher - * @throws IllegalStateException If there are no statuses present + * @return An unmodifiable set of statuses + * @see #statuses(Status, Status...) */ - @Contract(" -> new") - public @NotNull StatusWatcher build() throws IllegalStateException { - final boolean isEmptySuccess = this.successStatusSet.isEmpty(); - final boolean isEmptyFailure = this.failureStatusSet.isEmpty(); - - if ( - isEmptySuccess - && isEmptyFailure - ) { - throw new IllegalStateException("Cannot build watcher with no statuses"); - } + public @NotNull @Unmodifiable Set statuses() { + return Sets.union(this.successStatusSet, this.failureStatusSet); + } - final boolean hasAnyRunnable = - this.successRunnable != null - || this.failureRunnable != null; + /** + * Adds the specified statuses to the builder + * + * @param first First status + * @param rest Rest of the statuses + * @return This builder, for chaining + * @throws UnsupportedOperationException If any of the statuses is not + * supported + */ + @Contract("_, _ -> this") + public @NotNull Builder statuses( + final @NotNull Status first, + final Status @NotNull ... rest + ) throws UnsupportedOperationException { + this.successStatusSet = new ObjectOpenHashSet<>(); + this.failureStatusSet = new ObjectOpenHashSet<>(); - if ( - !isEmptySuccess - && !hasAnyRunnable - ) { - throw new IllegalStateException("Cannot build watcher with success statuses and no runnable"); - } + this.addStatus(first); - if ( - !isEmptyFailure - && !hasAnyRunnable - ) { - throw new IllegalStateException("Cannot build watcher with failure statuses and no runnable"); + for (final var status : rest) { + this.addStatus(status); } - return new StatusWatcher(this); + return this; } /** - * @return A set of success statuses, or an empty unmodifiable set - * if there are no success statuses + * Returns an unmodifiable set of success statuses + * + * @return An unmodifiable set of success statuses * @see #successStatuses(SuccessStatus, SuccessStatus...) */ - public @NotNull Set successStatuses() { - return this.successStatusSet; + public @NotNull @Unmodifiable Set successStatuses() { + return Collections.unmodifiableSet(this.successStatusSet); } /** @@ -465,21 +543,22 @@ private Builder() { * statuses provide a failure status, it will be added to the set of * failure statuses. * - * @param first First success status - * @param rest Rest of the success statuses - * @return This builder + * @param first First success status + * @param rest Rest of the success statuses + * @return This builder, for chaining */ @Contract("_, _ -> this") public @NotNull Builder successStatuses( final @NotNull SuccessStatus first, final SuccessStatus @NotNull ... rest ) { - this.successStatusSet = new ObjectOpenHashSet<>(rest); + this.successStatusSet = new ObjectOpenHashSet<>(rest.length + 1); this.successStatusSet.add(first); this.addFailureStatus(first.getFailureStatus()); for (final var status : rest) { + this.successStatusSet.add(status); this.addFailureStatus(status.getFailureStatus()); } @@ -487,34 +566,38 @@ private Builder() { } /** - * @return A set of failure statuses, or an empty unmodifiable set - * if there are no failure statuses + * Returns an unmodifiable set of failure statuses + * + * @return An unmodifiable set of failure statuses * @see #failureStatuses(FailureStatus, FailureStatus...) */ - public @NotNull Set failureStatuses() { - return this.failureStatusSet; + public @NotNull @Unmodifiable Set failureStatuses() { + return Collections.unmodifiableSet(this.failureStatusSet); } /** * Sets the failure statuses for the watcher * - * @param first First failure status - * @param rest Rest of the failure statuses - * @return This builder + * @param first First failure status + * @param rest Rest of the failure statuses + * @return This builder, for chaining */ @Contract("_, _ -> this") public @NotNull Builder failureStatuses( final @NotNull FailureStatus first, final FailureStatus @NotNull ... rest ) { - this.failureStatusSet = new ObjectOpenHashSet<>(rest); + this.failureStatusSet = new ObjectOpenHashSet<>(rest.length + 1); this.failureStatusSet.add(first); + this.failureStatusSet.addAll(Arrays.asList(rest)); return this; } /** + * Returns the success runnable + * * @return The success runnable * @see #successRunnable(Runnable) */ @@ -528,17 +611,19 @@ private Builder() { * {@link #anySuccess} is true, when any success status has been * triggered successfully. * - * @param successRunnable The success runnable - * @return This builder + * @param runnable The runnable + * @return This builder, for chaining */ @Contract("_ -> this") - public @NotNull Builder successRunnable(final @Nullable Runnable successRunnable) { - this.successRunnable = successRunnable; + public @NotNull Builder successRunnable(final @Nullable Runnable runnable) { + this.successRunnable = runnable; return this; } /** + * Returns the failure runnable + * * @return The failure runnable * @see #failureRunnable(Runnable) */ @@ -552,35 +637,41 @@ private Builder() { * {@link #anyFailure} is true, when any failure status has been * triggered successfully. * - * @param failureRunnable The failure runnable - * @return This builder + * @param runnable The runnable + * @return This builder, for chaining */ @Contract("_ -> this") - public @NotNull Builder failureRunnable(final @Nullable Runnable failureRunnable) { - this.failureRunnable = failureRunnable; + public @NotNull Builder failureRunnable(final @Nullable Runnable runnable) { + this.failureRunnable = runnable; return this; } /** - * @return Whether any success status will trigger the - * success-runnable, even if there are other success - * statuses that have not been triggered yet. Otherwise, - * the success-runnable will only be triggered if all - * success statuses have been triggered successfully. + * Returns whether any success status will trigger the success-runnable, + * even if there are other success statuses that have not been + * triggered yet. + *
+ * Otherwise, the success-runnable will only be triggered if all + * success statuses have been triggered successfully. + * + * @return Whether any success status will trigger the success-runnable */ public boolean anySuccess() { return this.anySuccess; } /** + * Sets whether any success status will trigger the success-runnable, + * even if there are other success statuses that have not been + * triggered yet. + *
+ * Otherwise, the success-runnable will only be triggered if all + * success statuses have been triggered successfully. + * * @param anySuccess Whether any success status will trigger the - * success-runnable, even if there are other - * success statuses that have not been triggered - * yet. Otherwise, the success-runnable will only - * be triggered if all success statuses have been - * triggered successfully. - * @return This builder + * success-runnable + * @return This builder, for chaining */ @Contract("_ -> this") public @NotNull Builder anySuccess(final boolean anySuccess) { @@ -590,24 +681,30 @@ public boolean anySuccess() { } /** - * @return Whether any failure status will trigger the - * failure-runnable, even if there are other failure - * statuses that have not been triggered yet. Otherwise, - * the failure-runnable will only be triggered if all - * failure statuses have been triggered successfully. + * Returns whether any failure status will trigger the failure-runnable, + * even if there are other failure statuses that have not been + * triggered yet. + *
+ * Otherwise, the failure-runnable will only be triggered if all + * failure statuses have been triggered successfully. + * + * @return Whether any failure status will trigger the failure-runnable */ public boolean anyFailure() { return this.anyFailure; } /** + * Sets whether any failure status will trigger the failure-runnable, + * even if there are other failure statuses that have not been + * triggered yet. + *
+ * Otherwise, the failure-runnable will only be triggered if all + * failure statuses have been triggered successfully. + * * @param anyFailure Whether any failure status will trigger the - * failure-runnable, even if there are other - * failure statuses that have not been triggered - * yet. Otherwise, the failure-runnable will only - * be triggered if all failure statuses have been - * triggered successfully. - * @return This builder + * failure-runnable + * @return This builder, for chaining */ @Contract("_ -> this") public @NotNull Builder anyFailure(final boolean anyFailure) { @@ -616,6 +713,72 @@ public boolean anyFailure() { return this; } + /** + * Builds a new watcher from the builder values + * + * @return A new status watcher + * @throws IllegalStateException If there are no statuses, or if there + * are no runnables + */ + @Contract(" -> new") + public @NotNull StatusWatcher build() throws IllegalStateException { + if ( + this.successStatusSet.isEmpty() + && this.failureStatusSet.isEmpty() + ) { + throw new IllegalStateException("Provide at least one status"); + } + + if ( + this.successRunnable == null + && this.failureRunnable == null + ) { + throw new IllegalStateException("Provide success and/or failure runnables"); + } + + return new StatusWatcher(this); + } + + /** + * Returns a string representation of the builder + * + * @return A string representation of the builder + */ + @Override + public @NotNull String toString() { + return FORMAT.formatted( + "StatusWatcher.Builder", + Joiner.on(", ").join(this.successStatusSet), + Joiner.on(", ").join(this.failureStatusSet), + this.successRunnable, + this.failureRunnable, + this.anySuccess, + this.anyFailure + ); + } + + private void addStatus(final @Nullable Status status) throws UnsupportedOperationException { + if (status != null) { + status.accept( + this::addSuccessStatus, + this::addFailureStatus + ); + } + } + + private void addSuccessStatus(final @Nullable SuccessStatus status) { + if (status == null) { + return; + } + + if (this.successStatusSet.isEmpty()) { + this.successStatusSet = new ObjectOpenHashSet<>(); + } + + this.successStatusSet.add(status); + this.addFailureStatus(status.getFailureStatus()); + } + private void addFailureStatus(final @Nullable FailureStatus status) { if (status == null) { return; diff --git a/src/main/java/com/minersstudios/mscore/status/SuccessStatus.java b/src/main/java/com/minersstudios/mscore/status/SuccessStatus.java new file mode 100644 index 00000000..715dccfd --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/status/SuccessStatus.java @@ -0,0 +1,81 @@ +package com.minersstudios.mscore.status; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.annotation.concurrent.Immutable; +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * Represents a successful status. + *
+ * Factory methods for creating a successful status: + *
    + *
  • {@link #success(String, Priority)}
  • + *
  • {@link #success(String, Priority, FailureStatus)}
  • + *
  • {@link #successLow(String)} + *
  • {@link #successLow(String, FailureStatus)}
  • + *
  • {@link #successHigh(String)}
  • + *
  • {@link #successHigh(String, FailureStatus)}
  • + *
+ * + * @see Status + */ +@Immutable +public class SuccessStatus extends ImplStatus { + private final FailureStatus failureStatus; + + protected SuccessStatus( + final @StatusKey @NotNull String key, + final @NotNull Priority priority, + final @Nullable FailureStatus failureStatus + ) { + super(key, priority); + + this.failureStatus = failureStatus; + } + + /** + * Returns the failure status for this successful status + * + * @return The failure status, or null if there is no failure status present + */ + public final @Nullable FailureStatus getFailureStatus() { + return this.failureStatus; + } + + @Override + public int hashCode() { + return this.failureStatus == null + ? super.hashCode() + : 31 * super.hashCode() + this.failureStatus.hashCode(); + } + + @Override + public @NotNull String toString() { + return this.getKey() + + "{priority=" + this.getPriority() + + ", failureStatus=" + this.failureStatus + + '}'; + } + + @ApiStatus.OverrideOnly + @Override + public void accept( + final @NotNull Consumer onSuccess, + final @Nullable Consumer onFailure + ) { + onSuccess.accept(this); + } + + @ApiStatus.OverrideOnly + @Override + public @NotNull U apply( + final @NotNull Function onSuccess, + final @Nullable Function onFailure + ) { + return onSuccess.apply(this); + } +} diff --git a/src/main/java/com/minersstudios/mscore/status/package-info.java b/src/main/java/com/minersstudios/mscore/status/package-info.java new file mode 100644 index 00000000..a38caaae --- /dev/null +++ b/src/main/java/com/minersstudios/mscore/status/package-info.java @@ -0,0 +1,10 @@ +/** + * This package contains classes and interfaces related to statuses and their + * management. They are thread-safe and can be safely used to manage plugin + * statuses in a multi-threaded environment. + * + * @see com.minersstudios.mscore.status.Status + * @see com.minersstudios.mscore.status.StatusWatcher + * @see com.minersstudios.mscore.status.StatusHandler + */ +package com.minersstudios.mscore.status; diff --git a/src/main/java/com/minersstudios/mscore/utility/DateUtils.java b/src/main/java/com/minersstudios/mscore/utility/DateUtils.java index 2f216da8..1df5b55c 100644 --- a/src/main/java/com/minersstudios/mscore/utility/DateUtils.java +++ b/src/main/java/com/minersstudios/mscore/utility/DateUtils.java @@ -97,7 +97,7 @@ private DateUtils() throws AssertionError { if (address == null) { return date .atZone(DEFAULT_ZONE_ID) - .format(MSPlugin.globalConfig().getTimeFormatter()); + .format(MSPlugin.globalConfig().getDateFormatter()); } final String timeZone = getTimezone(address); @@ -107,7 +107,7 @@ private DateUtils() throws AssertionError { ? "Europe/Kiev" : timeZone ) - ).format(MSPlugin.globalConfig().getTimeFormatter()); + ).format(MSPlugin.globalConfig().getDateFormatter()); } /** diff --git a/src/main/java/com/minersstudios/mscore/utility/SharedConstants.java b/src/main/java/com/minersstudios/mscore/utility/SharedConstants.java index 2195a7f4..d49160df 100644 --- a/src/main/java/com/minersstudios/mscore/utility/SharedConstants.java +++ b/src/main/java/com/minersstudios/mscore/utility/SharedConstants.java @@ -1,7 +1,11 @@ package com.minersstudios.mscore.utility; +import net.kyori.adventure.translation.Translator; import org.jetbrains.annotations.Contract; +import java.util.Locale; +import java.util.Objects; + import static io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR; /** @@ -17,15 +21,16 @@ public final class SharedConstants { public static final String PAPER_GLOBAL_CONFIG_PATH = CONFIG_DIR + '/' + PAPER_GLOBAL_CONFIG_FILE_NAME; public static final String PAPER_WORLD_DEFAULTS_PATH = CONFIG_DIR + '/' + PAPER_WORLD_DEFAULTS_CONFIG_FILE_NAME; public static final String DATE_FORMAT = "EEE, yyyy-MM-dd HH:mm z"; - public static final String LANGUAGE_CODE = "uk_ua"; - public static final String LANGUAGE_FOLDER_LINK = "https://raw.githubusercontent.com/MinersStudios/WMConfig/release/lang/"; + public static final String DEFAULT_LANGUAGE_CODE = "en_us"; public static final String DISCORD_LINK = "https://discord.whomine.net"; public static final String CONSOLE_NICKNAME = "$Console"; public static final String INVISIBLE_ITEM_FRAME_TAG = "invisibleItemFrame"; public static final String HIDE_TAGS_TEAM_NAME = "hide_tags"; + public static final String WHOMINE_NAMESPACE = "whomine"; public static final String MSBLOCK_NAMESPACE = "msblock"; public static final String MSITEMS_NAMESPACE = "msitems"; public static final String MSDECOR_NAMESPACE = "msdecor"; + public static final Locale DEFAULT_LOCALE = Objects.requireNonNull(Translator.parseLocale(DEFAULT_LANGUAGE_CODE), "Not found default locale for " + DEFAULT_LANGUAGE_CODE); public static final int SIT_RANGE = 9; public static final int FINAL_DESTROY_STAGE = 9; public static final int LEATHER_HORSE_ARMOR_MAX_STACK_SIZE = 8; diff --git a/src/main/java/com/minersstudios/mscustoms/Config.java b/src/main/java/com/minersstudios/mscustoms/Config.java index c046383d..6b4c3a54 100644 --- a/src/main/java/com/minersstudios/mscustoms/Config.java +++ b/src/main/java/com/minersstudios/mscustoms/Config.java @@ -2,7 +2,7 @@ import com.minersstudios.mscore.plugin.MSPlugin; import com.minersstudios.mscore.plugin.config.PluginConfig; -import com.minersstudios.mscore.plugin.status.StatusWatcher; +import com.minersstudios.mscore.status.StatusWatcher; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscustoms.custom.block.CustomBlockData; import com.minersstudios.mscustoms.custom.block.CustomBlockRegistry; @@ -12,6 +12,7 @@ import com.minersstudios.mscustoms.menu.RenamesMenu; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.configuration.ConfigurationSection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.UnknownNullability; @@ -29,11 +30,11 @@ * save configuration. */ public final class Config extends PluginConfig { + private long dosimeterCheckRate; private String woodSoundPlace; private String woodSoundBreak; private String woodSoundStep; private String woodSoundHit; - private long dosimeterCheckRate; // private static final String JSON_EXTENSION = ".json"; @@ -58,40 +59,55 @@ public final class Config extends PluginConfig { public static final String EXAMPLE_RENAMEABLE_FILE_PATH = ITEMS_FOLDER + '/' + EXAMPLE_RENAMEABLE_FILE_NAME; // - /** - * Configuration constructor - * - * @param plugin The plugin that owns this config - */ + // + public static final String KEY_DOSIMETER_CHECK_RATE = "dosimeter-check-rate"; + + public static final String KEY_WOOD_SOUND_SECTION = "wood-sound"; + public static final String KEY_PLACE = "place"; + public static final String KEY_BREAK = "break"; + public static final String KEY_STEP = "step"; + public static final String KEY_HIT = "hit"; + // + + // + public static final long DEFAULT_DOSIMETER_CHECK_RATE = 100; + public static final String DEFAULT_WOOD_SOUND_PLACE = "custom.block.wood.place"; + public static final String DEFAULT_WOOD_SOUND_BREAK = "custom.block.wood.break"; + public static final String DEFAULT_WOOD_SOUND_STEP = "custom.block.wood.step"; + public static final String DEFAULT_WOOD_SOUND_HIT = "custom.block.wood.hit"; + // + Config(final @NotNull MSCustoms plugin) { super(plugin, plugin.getConfigFile()); } - /** - * Reloads config variables - */ @Override public void reloadVariables() { - this.woodSoundPlace = this.yaml.getString("wood-sound.place"); - this.woodSoundBreak = this.yaml.getString("wood-sound.break"); - this.woodSoundStep = this.yaml.getString("wood-sound.step"); - this.woodSoundHit = this.yaml.getString("wood-sound.hit"); - this.dosimeterCheckRate = this.yaml.getLong("dosimeter-check-rate"); + this.dosimeterCheckRate = this.yaml.getLong(KEY_DOSIMETER_CHECK_RATE, DEFAULT_DOSIMETER_CHECK_RATE); + + final ConfigurationSection woodSoundSection = this.yaml.getConfigurationSection(KEY_WOOD_SOUND_SECTION); + + if (woodSoundSection != null) { + this.woodSoundPlace = woodSoundSection.getString(KEY_PLACE); + this.woodSoundBreak = woodSoundSection.getString(KEY_BREAK); + this.woodSoundStep = woodSoundSection.getString(KEY_STEP); + this.woodSoundHit = woodSoundSection.getString(KEY_HIT); + } if (ChatUtils.isBlank(this.woodSoundPlace)) { - this.woodSoundPlace = "block.wood.place"; + this.woodSoundPlace = DEFAULT_WOOD_SOUND_PLACE; } if (ChatUtils.isBlank(this.woodSoundBreak)) { - this.woodSoundBreak = "block.wood.break"; + this.woodSoundBreak = DEFAULT_WOOD_SOUND_BREAK; } if (ChatUtils.isBlank(this.woodSoundStep)) { - this.woodSoundStep = "block.wood.step"; + this.woodSoundStep = DEFAULT_WOOD_SOUND_STEP; } if (ChatUtils.isBlank(this.woodSoundHit)) { - this.woodSoundHit = "block.wood.hit"; + this.woodSoundHit = DEFAULT_WOOD_SOUND_HIT; } final MSCustoms plugin = this.getPlugin(); @@ -132,16 +148,21 @@ public void reloadVariables() { ); } - /** - * Reloads default config variables - */ @Override public void reloadDefaultVariables() { - this.setIfNotExists("wood-sound.place", "custom.block.wood.place"); - this.setIfNotExists("wood-sound.break", "custom.block.wood.break"); - this.setIfNotExists("wood-sound.step", "custom.block.wood.step"); - this.setIfNotExists("wood-sound.hit", "custom.block.wood.hit"); - this.setIfNotExists("dosimeter-check-rate", 100); + this.setIfNotExists(KEY_DOSIMETER_CHECK_RATE, DEFAULT_DOSIMETER_CHECK_RATE); + + this.setIfNotExists(KEY_WOOD_SOUND_SECTION + '.' + KEY_PLACE, DEFAULT_WOOD_SOUND_PLACE); + this.setIfNotExists(KEY_WOOD_SOUND_SECTION + '.' + KEY_BREAK, DEFAULT_WOOD_SOUND_BREAK); + this.setIfNotExists(KEY_WOOD_SOUND_SECTION + '.' + KEY_STEP, DEFAULT_WOOD_SOUND_STEP); + this.setIfNotExists(KEY_WOOD_SOUND_SECTION + '.' + KEY_HIT, DEFAULT_WOOD_SOUND_HIT); + } + + /** + * @return The dosimeter check rate + */ + public long getDosimeterCheckRate() { + return this.dosimeterCheckRate; } /** @@ -172,18 +193,11 @@ public void reloadDefaultVariables() { return this.woodSoundHit; } - /** - * @return The dosimeter check rate - */ - public long getDosimeterCheckRate() { - return this.dosimeterCheckRate; - } - private void loadBlocks() { final long start = System.currentTimeMillis(); final MSCustoms plugin = this.getPlugin(); - plugin.setStatus(MSCustoms.LOADING_BLOCKS); + plugin.assignStatus(MSCustoms.LOADING_BLOCKS); try (final var pathStream = Files.walk(Paths.get(this.file.getParent() + '/' + BLOCKS_FOLDER))) { pathStream.parallel() @@ -197,7 +211,7 @@ private void loadBlocks() { .filter(Objects::nonNull) .forEach(CustomBlockRegistry::register); - plugin.setStatus(MSCustoms.LOADED_BLOCKS); + plugin.assignStatus(MSCustoms.LOADED_BLOCKS); plugin.getComponentLogger().info( Component.text( "Loaded " + CustomBlockRegistry.size() + " custom blocks in " + (System.currentTimeMillis() - start) + "ms", @@ -205,7 +219,7 @@ private void loadBlocks() { ) ); } catch (final IOException e) { - plugin.setStatus(MSCustoms.FAILED_LOAD_BLOCKS); + plugin.assignStatus(MSCustoms.FAILED_LOAD_BLOCKS); plugin.getLogger().log( Level.SEVERE, "An error occurred while loading blocks", @@ -218,7 +232,7 @@ private void loadRenames() { final long start = System.currentTimeMillis(); final MSCustoms plugin = this.getPlugin(); - plugin.setStatus(MSCustoms.LOADING_RENAMEABLES); + plugin.assignStatus(MSCustoms.LOADING_RENAMEABLES); try (final var pathStream = Files.walk(Paths.get(this.file.getParent() + '/' + ITEMS_FOLDER))) { pathStream.parallel() @@ -232,7 +246,7 @@ private void loadRenames() { .filter(Objects::nonNull) .forEach(RenameableItemRegistry::register); - plugin.setStatus(MSCustoms.LOADED_RENAMEABLES); + plugin.assignStatus(MSCustoms.LOADED_RENAMEABLES); plugin.getComponentLogger().info( Component.text( "Loaded " + RenameableItemRegistry.keysSize() + " renameable items in " + (System.currentTimeMillis() - start) + "ms", @@ -242,7 +256,7 @@ private void loadRenames() { RenamesMenu.update(plugin); } catch (final IOException e) { - plugin.setStatus(MSCustoms.FAILED_LOAD_RENAMEABLES); + plugin.assignStatus(MSCustoms.FAILED_LOAD_RENAMEABLES); plugin.getLogger().log( Level.SEVERE, "An error occurred while loading renameable items", diff --git a/src/main/java/com/minersstudios/mscustoms/MSCustoms.java b/src/main/java/com/minersstudios/mscustoms/MSCustoms.java index b8b1971b..07263292 100644 --- a/src/main/java/com/minersstudios/mscustoms/MSCustoms.java +++ b/src/main/java/com/minersstudios/mscustoms/MSCustoms.java @@ -1,8 +1,8 @@ package com.minersstudios.mscustoms; import com.minersstudios.mscore.plugin.MSPlugin; -import com.minersstudios.mscore.plugin.status.FailureStatus; -import com.minersstudios.mscore.plugin.status.SuccessStatus; +import com.minersstudios.mscore.status.FailureStatus; +import com.minersstudios.mscore.status.SuccessStatus; import com.minersstudios.mscore.utility.ItemUtils; import com.minersstudios.mscore.utility.PaperUtils; import com.minersstudios.mscore.utility.SharedConstants; @@ -18,7 +18,8 @@ import java.util.concurrent.CompletableFuture; import java.util.logging.Logger; -import static com.minersstudios.mscore.plugin.status.SuccessStatus.low; +import static com.minersstudios.mscore.status.Status.failureLow; +import static com.minersstudios.mscore.status.Status.successLow; /** * The main class of the MSCustoms plugin @@ -32,19 +33,20 @@ public class MSCustoms extends MSPlugin { private Config config; // - public static final FailureStatus FAILED_LOAD_BLOCKS = FailureStatus.low("FAILED_LOAD_BLOCKS"); - public static final FailureStatus FAILED_LOAD_RENAMEABLES = FailureStatus.low("FAILED_LOAD_RENAMEABLES"); - - public static final SuccessStatus LOADING_DECORATIONS = low("LOADING_DECORATIONS"); - public static final SuccessStatus LOADED_DECORATIONS = low("LOADED_DECORATIONS"); - public static final SuccessStatus LOADING_BLOCKS = low("LOADING_BLOCKS"); - public static final SuccessStatus LOADED_BLOCKS = low("LOADED_BLOCKS", FAILED_LOAD_BLOCKS); - public static final SuccessStatus LOADING_ITEMS = low("LOADING_ITEMS"); - public static final SuccessStatus LOADED_ITEMS = low("LOADED_ITEMS"); - public static final SuccessStatus LOADING_RENAMEABLES = low("LOADING_RENAMEABLES"); - public static final SuccessStatus LOADED_RENAMEABLES = low("LOADED_RENAMEABLES", FAILED_LOAD_RENAMEABLES); + public static final FailureStatus FAILED_LOAD_BLOCKS = failureLow("FAILED_LOAD_BLOCKS"); + public static final FailureStatus FAILED_LOAD_RENAMEABLES = failureLow("FAILED_LOAD_RENAMEABLES"); + + public static final SuccessStatus LOADING_DECORATIONS = successLow("LOADING_DECORATIONS"); + public static final SuccessStatus LOADED_DECORATIONS = successLow("LOADED_DECORATIONS"); + public static final SuccessStatus LOADING_BLOCKS = successLow("LOADING_BLOCKS"); + public static final SuccessStatus LOADED_BLOCKS = successLow("LOADED_BLOCKS", FAILED_LOAD_BLOCKS); + public static final SuccessStatus LOADING_ITEMS = successLow("LOADING_ITEMS"); + public static final SuccessStatus LOADED_ITEMS = successLow("LOADED_ITEMS"); + public static final SuccessStatus LOADING_RENAMEABLES = successLow("LOADING_RENAMEABLES"); + public static final SuccessStatus LOADED_RENAMEABLES = successLow("LOADED_RENAMEABLES", FAILED_LOAD_RENAMEABLES); // + /** The namespace of the plugin */ public static final String NAMESPACE = "mscustoms"; static { @@ -88,6 +90,8 @@ public void disable() { } /** + * Returns the cache of the plugin + * * @return The cache of the plugin or null if the plugin is disabled */ public @UnknownNullability Cache getCache() { diff --git a/src/main/java/com/minersstudios/mscustoms/command/block/GiveCommand.java b/src/main/java/com/minersstudios/mscustoms/command/block/GiveCommand.java index 768fc8e4..50dd8eae 100644 --- a/src/main/java/com/minersstudios/mscustoms/command/block/GiveCommand.java +++ b/src/main/java/com/minersstudios/mscustoms/command/block/GiveCommand.java @@ -1,8 +1,7 @@ package com.minersstudios.mscustoms.command.block; -import com.minersstudios.mscustoms.custom.block.CustomBlockRegistry; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.plugin.MSLogger; +import com.minersstudios.mscustoms.custom.block.CustomBlockRegistry; import com.minersstudios.msessentials.MSEssentials; import com.minersstudios.msessentials.player.PlayerInfo; import org.bukkit.command.CommandSender; @@ -10,6 +9,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; public final class GiveCommand { @@ -30,8 +30,9 @@ public static boolean runCommand( if (playerInfo == null) { MSLogger.severe( sender, - LanguageRegistry.Components.ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } @@ -40,8 +41,9 @@ public static boolean runCommand( if (player == null) { MSLogger.warning( sender, - LanguageRegistry.Components.ERROR_PLAYER_NOT_ONLINE + ERROR_PLAYER_NOT_ONLINE.asTranslatable() ); + return true; } @@ -54,8 +56,9 @@ public static boolean runCommand( } catch (final NumberFormatException ignore) { MSLogger.severe( sender, - LanguageRegistry.Components.ERROR_WRONG_FORMAT + ERROR_WRONG_FORMAT.asTranslatable() ); + return; } @@ -65,7 +68,7 @@ public static boolean runCommand( player.getInventory().addItem(itemStack); MSLogger.fine( sender, - LanguageRegistry.Components.COMMAND_MSBLOCK_GIVE_SUCCESS + COMMAND_MSBLOCK_GIVE_SUCCESS.asTranslatable() .arguments( text(amount), itemStack.displayName(), @@ -75,7 +78,7 @@ public static boolean runCommand( }, () -> MSLogger.severe( sender, - LanguageRegistry.Components.COMMAND_MSBLOCK_GIVE_WRONG_BLOCK + COMMAND_MSBLOCK_GIVE_WRONG_BLOCK.asTranslatable() ) ); diff --git a/src/main/java/com/minersstudios/mscustoms/command/block/ReloadCommand.java b/src/main/java/com/minersstudios/mscustoms/command/block/ReloadCommand.java index f6a264db..0c9e3556 100644 --- a/src/main/java/com/minersstudios/mscustoms/command/block/ReloadCommand.java +++ b/src/main/java/com/minersstudios/mscustoms/command/block/ReloadCommand.java @@ -2,7 +2,7 @@ import com.minersstudios.mscustoms.MSCustoms; import com.minersstudios.mscustoms.custom.block.CustomBlockRegistry; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -27,7 +27,7 @@ public static boolean runCommand( plugin.getConfiguration().reload(); MSLogger.fine( sender, - LanguageRegistry.Components.COMMAND_MSBLOCK_RELOAD_SUCCESS + Translations.COMMAND_MSBLOCK_RELOAD_SUCCESS.asTranslatable() .arguments(text(System.currentTimeMillis() - time)) ); diff --git a/src/main/java/com/minersstudios/mscustoms/command/decor/GiveCommand.java b/src/main/java/com/minersstudios/mscustoms/command/decor/GiveCommand.java index 07819c26..49bebeb0 100644 --- a/src/main/java/com/minersstudios/mscustoms/command/decor/GiveCommand.java +++ b/src/main/java/com/minersstudios/mscustoms/command/decor/GiveCommand.java @@ -9,7 +9,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; public final class GiveCommand { @@ -33,7 +33,7 @@ public static boolean runCommand( if (playerInfo == null) { MSLogger.severe( sender, - ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); return true; } @@ -43,7 +43,7 @@ public static boolean runCommand( if (player == null) { MSLogger.warning( sender, - ERROR_PLAYER_NOT_ONLINE + ERROR_PLAYER_NOT_ONLINE.asTranslatable() ); return true; } @@ -57,7 +57,7 @@ public static boolean runCommand( } catch (final NumberFormatException ignore) { MSLogger.severe( sender, - ERROR_WRONG_FORMAT + ERROR_WRONG_FORMAT.asTranslatable() ); return; } @@ -68,7 +68,7 @@ public static boolean runCommand( player.getInventory().addItem(itemStack); MSLogger.fine( sender, - COMMAND_MSDECOR_GIVE_SUCCESS + COMMAND_MSDECOR_GIVE_SUCCESS.asTranslatable() .arguments( text(amount), itemStack.displayName(), @@ -78,7 +78,7 @@ public static boolean runCommand( }, () -> MSLogger.severe( sender, - COMMAND_MSDECOR_GIVE_WRONG_DECOR + COMMAND_MSDECOR_GIVE_WRONG_DECOR.asTranslatable() ) ); diff --git a/src/main/java/com/minersstudios/mscustoms/command/item/GiveCommand.java b/src/main/java/com/minersstudios/mscustoms/command/item/GiveCommand.java index 6139921e..146473db 100644 --- a/src/main/java/com/minersstudios/mscustoms/command/item/GiveCommand.java +++ b/src/main/java/com/minersstudios/mscustoms/command/item/GiveCommand.java @@ -1,6 +1,6 @@ package com.minersstudios.mscustoms.command.item; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.msessentials.MSEssentials; import com.minersstudios.msessentials.player.PlayerInfo; @@ -30,7 +30,7 @@ public static boolean runCommand( if (playerInfo == null) { MSLogger.severe( sender, - LanguageRegistry.Components.ERROR_PLAYER_NOT_FOUND + Translations.ERROR_PLAYER_NOT_FOUND.asTranslatable() ); return true; } @@ -40,7 +40,7 @@ public static boolean runCommand( if (player == null) { MSLogger.warning( sender, - LanguageRegistry.Components.ERROR_PLAYER_NOT_ONLINE + Translations.ERROR_PLAYER_NOT_ONLINE.asTranslatable() ); return true; } @@ -54,7 +54,7 @@ public static boolean runCommand( } catch (final NumberFormatException ignored) { MSLogger.severe( sender, - LanguageRegistry.Components.ERROR_WRONG_FORMAT + Translations.ERROR_WRONG_FORMAT.asTranslatable() ); return; } @@ -65,7 +65,7 @@ public static boolean runCommand( player.getInventory().addItem(itemStack); MSLogger.fine( sender, - LanguageRegistry.Components.COMMAND_MSITEM_GIVE_SUCCESS + Translations.COMMAND_MSITEM_GIVE_SUCCESS.asTranslatable() .arguments( text(amount), itemStack.displayName(), @@ -75,7 +75,7 @@ public static boolean runCommand( }, () -> MSLogger.severe( sender, - LanguageRegistry.Components.COMMAND_MSITEM_GIVE_WRONG_ITEM + Translations.COMMAND_MSITEM_GIVE_WRONG_ITEM.asTranslatable() ) ); diff --git a/src/main/java/com/minersstudios/mscustoms/command/item/ReloadCommand.java b/src/main/java/com/minersstudios/mscustoms/command/item/ReloadCommand.java index 852eb3ec..9e2fec5a 100644 --- a/src/main/java/com/minersstudios/mscustoms/command/item/ReloadCommand.java +++ b/src/main/java/com/minersstudios/mscustoms/command/item/ReloadCommand.java @@ -1,6 +1,6 @@ package com.minersstudios.mscustoms.command.item; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.plugin.MSPlugin; import com.minersstudios.mscore.utility.SharedConstants; @@ -41,7 +41,7 @@ public static boolean runCommand( plugin.getConfiguration().reload(); MSLogger.fine( sender, - LanguageRegistry.Components.COMMAND_MSITEM_RELOAD_SUCCESS + Translations.COMMAND_MSITEM_RELOAD_SUCCESS.asTranslatable() .arguments(text(System.currentTimeMillis() - time)) ); diff --git a/src/main/java/com/minersstudios/mscustoms/custom/block/CustomBlockRegistry.java b/src/main/java/com/minersstudios/mscustoms/custom/block/CustomBlockRegistry.java index a31c6101..b913d280 100644 --- a/src/main/java/com/minersstudios/mscustoms/custom/block/CustomBlockRegistry.java +++ b/src/main/java/com/minersstudios/mscustoms/custom/block/CustomBlockRegistry.java @@ -89,7 +89,7 @@ public final class CustomBlockRegistry { @Contract(" -> fail") private CustomBlockRegistry() throws AssertionError { - throw new AssertionError("Registry class"); + throw new AssertionError("Utility class"); } /** diff --git a/src/main/java/com/minersstudios/mscustoms/custom/block/file/adapter/RecipeChoiceAdapter.java b/src/main/java/com/minersstudios/mscustoms/custom/block/file/adapter/RecipeChoiceAdapter.java index d731b51b..f48917c3 100644 --- a/src/main/java/com/minersstudios/mscustoms/custom/block/file/adapter/RecipeChoiceAdapter.java +++ b/src/main/java/com/minersstudios/mscustoms/custom/block/file/adapter/RecipeChoiceAdapter.java @@ -61,6 +61,7 @@ public class RecipeChoiceAdapter implements JsonSerializer, JsonDe jsonObject.get(CHOICES_KEY), NAMESPACED_LIST_TYPE ); + return new CustomChoice(namespacedKeys).toExactChoice(); } default -> throw new IllegalArgumentException("Unknown RecipeChoice type : " + typeString); @@ -89,7 +90,7 @@ public class RecipeChoiceAdapter implements JsonSerializer, JsonDe } else if (choice instanceof final RecipeChoice.ExactChoice exactChoice) { jsonObject.add(CHOICES_KEY, context.serialize(exactChoice.getChoices())); } else if (choice instanceof final CustomChoice customChoice) { - jsonObject.add(CHOICES_KEY, context.serialize(customChoice.getNamespacedKeys())); + jsonObject.add(CHOICES_KEY, context.serialize(customChoice.namespacedKeySet())); } else { throw new IllegalArgumentException("Unknown RecipeChoice type: " + choice.getClass().getName()); } diff --git a/src/main/java/com/minersstudios/mscustoms/custom/block/file/adapter/RecipeEntryAdapter.java b/src/main/java/com/minersstudios/mscustoms/custom/block/file/adapter/RecipeEntryAdapter.java index c2ac406e..43ccff98 100644 --- a/src/main/java/com/minersstudios/mscustoms/custom/block/file/adapter/RecipeEntryAdapter.java +++ b/src/main/java/com/minersstudios/mscustoms/custom/block/file/adapter/RecipeEntryAdapter.java @@ -30,7 +30,7 @@ public class RecipeEntryAdapter implements JsonSerializer, JsonDese throw new JsonParseException("Missing showInCraftsMenu"); } - return RecipeEntry.of( + return RecipeEntry.fromRecipe( (Recipe) context.deserialize( recipeElement, Recipe.class diff --git a/src/main/java/com/minersstudios/mscustoms/custom/decor/CustomDecorDataImpl.java b/src/main/java/com/minersstudios/mscustoms/custom/decor/CustomDecorDataImpl.java index 8319ef3b..23c4ce36 100644 --- a/src/main/java/com/minersstudios/mscustoms/custom/decor/CustomDecorDataImpl.java +++ b/src/main/java/com/minersstudios/mscustoms/custom/decor/CustomDecorDataImpl.java @@ -657,7 +657,7 @@ public void registerRecipes(final @NotNull Server server) { } this.recipeEntries.add( - RecipeEntry.of( + RecipeEntry.fromRecipe( recipe, registerInMenu ) diff --git a/src/main/java/com/minersstudios/mscustoms/custom/decor/CustomDecorType.java b/src/main/java/com/minersstudios/mscustoms/custom/decor/CustomDecorType.java index 6105ad35..f8d9a639 100644 --- a/src/main/java/com/minersstudios/mscustoms/custom/decor/CustomDecorType.java +++ b/src/main/java/com/minersstudios/mscustoms/custom/decor/CustomDecorType.java @@ -1,7 +1,7 @@ package com.minersstudios.mscustoms.custom.decor; import com.minersstudios.mscore.plugin.MSPlugin; -import com.minersstudios.mscore.plugin.status.StatusWatcher; +import com.minersstudios.mscore.status.StatusWatcher; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.SharedConstants; import com.minersstudios.mscustoms.MSCustoms; @@ -221,7 +221,7 @@ public static void load(final @NotNull MSCustoms plugin) throws IllegalStateExce final long startTime = System.currentTimeMillis(); final var typesWithRecipes = new ObjectArrayList(); - plugin.setStatus(MSCustoms.LOADING_DECORATIONS); + plugin.assignStatus(MSCustoms.LOADING_DECORATIONS); Stream.of(VALUES).parallel() .forEach(type -> { final CustomDecorData data; @@ -246,7 +246,7 @@ public static void load(final @NotNull MSCustoms plugin) throws IllegalStateExce } }); typesWithRecipes.sort(Comparator.comparingInt(CustomDecorType::ordinal)); - plugin.setStatus(MSCustoms.LOADED_DECORATIONS); + plugin.assignStatus(MSCustoms.LOADED_DECORATIONS); plugin.getComponentLogger().info( Component.text( diff --git a/src/main/java/com/minersstudios/mscustoms/custom/item/CustomItemType.java b/src/main/java/com/minersstudios/mscustoms/custom/item/CustomItemType.java index 8428a175..3b53914e 100644 --- a/src/main/java/com/minersstudios/mscustoms/custom/item/CustomItemType.java +++ b/src/main/java/com/minersstudios/mscustoms/custom/item/CustomItemType.java @@ -1,7 +1,7 @@ package com.minersstudios.mscustoms.custom.item; import com.minersstudios.mscore.plugin.MSPlugin; -import com.minersstudios.mscore.plugin.status.StatusWatcher; +import com.minersstudios.mscore.status.StatusWatcher; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.SharedConstants; import com.minersstudios.mscustoms.MSCustoms; @@ -91,7 +91,7 @@ public static void load(final @NotNull MSCustoms plugin) throws IllegalStateExce final long startTime = System.currentTimeMillis(); final var typesWithRecipes = new ObjectArrayList(); - plugin.setStatus(MSCustoms.LOADING_ITEMS); + plugin.assignStatus(MSCustoms.LOADING_ITEMS); Stream.of(VALUES).parallel() .forEach(type -> { final CustomItem customItem; @@ -120,7 +120,7 @@ public static void load(final @NotNull MSCustoms plugin) throws IllegalStateExce } }); typesWithRecipes.sort(Comparator.comparingInt(CustomItemType::ordinal)); - plugin.setStatus(MSCustoms.LOADED_ITEMS); + plugin.assignStatus(MSCustoms.LOADED_ITEMS); plugin.getComponentLogger().info( Component.text( diff --git a/src/main/java/com/minersstudios/mscustoms/menu/CraftsMenu.java b/src/main/java/com/minersstudios/mscustoms/menu/CraftsMenu.java index f81b053e..b752eb27 100644 --- a/src/main/java/com/minersstudios/mscustoms/menu/CraftsMenu.java +++ b/src/main/java/com/minersstudios/mscustoms/menu/CraftsMenu.java @@ -17,7 +17,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static com.minersstudios.mscore.utility.ChatUtils.DEFAULT_STYLE; public final class CraftsMenu { @@ -61,7 +61,7 @@ public final class CraftsMenu { CATEGORIES_INVENTORY = CustomInventory.single( - MENU_CRAFTS_CATEGORIES_TITLE.style(DEFAULT_STYLE), + MENU_CRAFTS_CATEGORIES_TITLE.asComponent().style(DEFAULT_STYLE), 4 ) .buttons( @@ -80,8 +80,8 @@ public final class CraftsMenu { .collect(Collectors.toMap(Function.identity(), slot -> itemsButton)) ); - final Component previousButton = MENU_CRAFTS_BUTTON_PREVIOUS_PAGE.style(DEFAULT_STYLE); - final Component nextButton = MENU_CRAFTS_BUTTON_NEXT_PAGE.style(DEFAULT_STYLE); + final Component previousButton = MENU_CRAFTS_BUTTON_PREVIOUS_PAGE.asComponent().style(DEFAULT_STYLE); + final Component nextButton = MENU_CRAFTS_BUTTON_NEXT_PAGE.asComponent().style(DEFAULT_STYLE); final ItemStack previousPageItem = new ItemStack(Material.PAPER); final ItemMeta previousPageMeta = previousPageItem.getItemMeta(); @@ -166,7 +166,7 @@ public static void putCrafts( final ItemStack resultItem = recipe.getResult(); final SingleInventory craftInventory = CustomInventory.single( - MENU_CRAFTS_CRAFT_TITLE.style(DEFAULT_STYLE), + MENU_CRAFTS_CRAFT_TITLE.asTranslatable().style(DEFAULT_STYLE), 4 ); @@ -260,7 +260,7 @@ public static void open( private static @NotNull ElementPagedInventory buildCraftsInventory() { return CustomInventory .elementPaged( - MENU_CRAFTS_CATEGORY_TITLE.style(DEFAULT_STYLE), + MENU_CRAFTS_CATEGORY_TITLE.asTranslatable().style(DEFAULT_STYLE), 5, IntStream.range(0, 36).toArray() ) diff --git a/src/main/java/com/minersstudios/mscustoms/menu/RenamesMenu.java b/src/main/java/com/minersstudios/mscustoms/menu/RenamesMenu.java index 448fe80c..c5b295a7 100644 --- a/src/main/java/com/minersstudios/mscustoms/menu/RenamesMenu.java +++ b/src/main/java/com/minersstudios/mscustoms/menu/RenamesMenu.java @@ -1,7 +1,7 @@ package com.minersstudios.mscustoms.menu; import com.minersstudios.mscore.inventory.*; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscustoms.MSCustoms; import com.minersstudios.mscustoms.custom.item.renameable.RenameCollection; @@ -43,9 +43,9 @@ public final class RenamesMenu { private static final ElementPagedInventory INVENTORY; static { - final Component previousButtonComponent = LanguageRegistry.Components.MENU_RENAMES_BUTTON_PREVIOUS_PAGE.style(ChatUtils.DEFAULT_STYLE); - final Component nextButtonComponent = LanguageRegistry.Components.MENU_RENAMES_BUTTON_NEXT_PAGE.style(ChatUtils.DEFAULT_STYLE); - final Component redCrossComponent = LanguageRegistry.Components.MENU_RENAME_NO_EXP.style(ChatUtils.COLORLESS_DEFAULT_STYLE).color(NamedTextColor.GRAY); + final Component previousButtonComponent = Translations.MENU_RENAMES_BUTTON_PREVIOUS_PAGE.asComponent().style(ChatUtils.DEFAULT_STYLE); + final Component nextButtonComponent = Translations.MENU_RENAMES_BUTTON_NEXT_PAGE.asComponent().style(ChatUtils.DEFAULT_STYLE); + final Component redCrossComponent = Translations.MENU_RENAME_NO_EXP.asComponent().style(ChatUtils.COLORLESS_DEFAULT_STYLE).color(NamedTextColor.GRAY); final ItemStack previousPageItem = new ItemStack(Material.PAPER); final ItemMeta previousPageMeta = previousPageItem.getItemMeta(); @@ -116,7 +116,7 @@ public final class RenamesMenu { INVENTORY = CustomInventory .elementPaged( - LanguageRegistry.Components.MENU_RENAMES_TITLE.style(ChatUtils.DEFAULT_STYLE), + Translations.MENU_RENAMES_TITLE.asTranslatable().style(ChatUtils.DEFAULT_STYLE), 5, IntStream.range(0, 36).toArray() ) @@ -163,7 +163,7 @@ public static void update(final @NotNull MSCustoms plugin) { final Player player = (Player) buttonEvent.getWhoClicked(); final SingleInventory renameInventory = CustomInventory.single( - LanguageRegistry.Components.MENU_RENAME_TITLE.style(ChatUtils.DEFAULT_STYLE), + Translations.MENU_RENAME_TITLE.asTranslatable().style(ChatUtils.DEFAULT_STYLE), 5 ); diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/ChristmasBall.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/ChristmasBall.java index 9c3861e7..9e019db6 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/ChristmasBall.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/ChristmasBall.java @@ -61,8 +61,8 @@ public final class ChristmasBall extends CustomDecorDataImpl { return MSPlugin.globalConfig().isChristmas() ? builder0.recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " S ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/ChristmasTallBall.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/ChristmasTallBall.java index 437222ad..f21551b6 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/ChristmasTallBall.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/ChristmasTallBall.java @@ -61,8 +61,8 @@ public final class ChristmasTallBall extends CustomDecorDataImpl RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " S ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SantaSock.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SantaSock.java index 405994f3..03819cf7 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SantaSock.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SantaSock.java @@ -43,8 +43,8 @@ public final class SantaSock extends CustomDecorDataImpl { return MSPlugin.globalConfig().isChristmas() ? builder.recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "LA", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SnowflakeOnString.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SnowflakeOnString.java index 0fb9687f..86d63c06 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SnowflakeOnString.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SnowflakeOnString.java @@ -64,8 +64,8 @@ public final class SnowflakeOnString extends CustomDecorDataImpl RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " S ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/Snowman.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/Snowman.java index 447a37c3..5c5e1026 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/Snowman.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/Snowman.java @@ -57,8 +57,8 @@ public final class Snowman extends CustomDecorDataImpl { return MSPlugin.globalConfig().isChristmas() ? builder0.recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " L ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SnowmanBall.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SnowmanBall.java index e3271510..85a8746d 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SnowmanBall.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/SnowmanBall.java @@ -64,8 +64,8 @@ public final class SnowmanBall extends CustomDecorDataImpl { return MSPlugin.globalConfig().isChristmas() ? builder0.recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " S ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/StarOnString.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/StarOnString.java index b61c7567..bc7135c0 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/StarOnString.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/StarOnString.java @@ -64,8 +64,8 @@ public final class StarOnString extends CustomDecorDataImpl { return MSPlugin.globalConfig().isChristmas() ? builder0.recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " S ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/TreeStar.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/TreeStar.java index 09114a3a..6738315f 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/TreeStar.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/christmas/TreeStar.java @@ -41,8 +41,8 @@ public final class TreeStar extends CustomDecorDataImpl { return MSPlugin.globalConfig().isChristmas() ? builder.recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " I ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Cell.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Cell.java index 09a21f34..0fb6cfaa 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Cell.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Cell.java @@ -47,8 +47,8 @@ public final class Cell extends CustomDecorDataImpl { .soundGroup(SoundGroup.CHAIN) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " C ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/CookingPot.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/CookingPot.java index 7e5f89ba..a4d49171 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/CookingPot.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/CookingPot.java @@ -38,8 +38,8 @@ public final class CookingPot extends CustomDecorDataImpl { .soundGroup(SoundGroup.ANVIL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "ISI", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/OldCamera.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/OldCamera.java index b4596bda..9203727e 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/OldCamera.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/OldCamera.java @@ -37,8 +37,8 @@ public final class OldCamera extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " I ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Patefon.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Patefon.java index 1615adff..94c41d78 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Patefon.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Patefon.java @@ -37,8 +37,8 @@ public final class Patefon extends CustomDecorDataImpl { .soundGroup(SoundGroup.ANVIL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape("PJP") .ingredients( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Piggybank.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Piggybank.java index 978703c5..7844b907 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Piggybank.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Piggybank.java @@ -43,8 +43,8 @@ public abstract class Piggybank> extends CustomDeco .soundGroup(SoundGroup.GLASS) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .group(SharedConstants.MSDECOR_NAMESPACE + ":piggybank") .category(CraftingBookCategory.BUILDING) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/SmallClock.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/SmallClock.java index 2f51b9e0..7b50136a 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/SmallClock.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/SmallClock.java @@ -39,8 +39,8 @@ public final class SmallClock extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "LLL", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/SmallGlobe.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/SmallGlobe.java index c05d36a1..98d1f89e 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/SmallGlobe.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/SmallGlobe.java @@ -37,8 +37,8 @@ public final class SmallGlobe extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "M", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Whocintosh.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Whocintosh.java index e9bcf948..1607402c 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Whocintosh.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/Whocintosh.java @@ -38,8 +38,8 @@ public final class Whocintosh extends CustomDecorDataImpl { .soundGroup(SoundGroup.ANVIL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "III", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/DeerHead.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/DeerHead.java index 41c6dece..65614ec6 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/DeerHead.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/DeerHead.java @@ -38,8 +38,8 @@ public final class DeerHead extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "BBS", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/HoglinHead.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/HoglinHead.java index 40796bfe..6b25371a 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/HoglinHead.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/HoglinHead.java @@ -38,8 +38,8 @@ public final class HoglinHead extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " PS", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/ZoglinHead.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/ZoglinHead.java index bf580456..1a0c8684 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/ZoglinHead.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/head/ZoglinHead.java @@ -38,8 +38,8 @@ public final class ZoglinHead extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " FS", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/BMOPlush.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/BMOPlush.java index 5a59b51d..0fc3c41d 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/BMOPlush.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/BMOPlush.java @@ -37,8 +37,8 @@ public final class BMOPlush extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "II", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/BrownBearPlush.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/BrownBearPlush.java index 6ae32a23..a4d4a7e3 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/BrownBearPlush.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/BrownBearPlush.java @@ -37,8 +37,8 @@ public final class BrownBearPlush extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "AWA", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/RacoonPlush.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/RacoonPlush.java index 001a1bbe..dbe6c82a 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/RacoonPlush.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/RacoonPlush.java @@ -38,8 +38,8 @@ public final class RacoonPlush extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "WWW", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/WhocintoshMini.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/WhocintoshMini.java index 7c05eb3a..4b88610a 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/WhocintoshMini.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/home/plush/WhocintoshMini.java @@ -42,8 +42,8 @@ public final class WhocintoshMini extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "WWW", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/Brazier.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/Brazier.java index 7069ae9e..78f58e04 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/Brazier.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/Brazier.java @@ -49,8 +49,8 @@ public final class Brazier extends CustomDecorDataImpl { .soundGroup(SoundGroup.CHAIN) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "B B", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/FireHydrant.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/FireHydrant.java index 9080111a..f69b7be0 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/FireHydrant.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/FireHydrant.java @@ -38,8 +38,8 @@ public final class FireHydrant extends CustomDecorDataImpl { .soundGroup(SoundGroup.ANVIL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( " B ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/IronTrashcan.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/IronTrashcan.java index e3a71d64..c0f8e1b3 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/IronTrashcan.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/IronTrashcan.java @@ -45,8 +45,8 @@ public final class IronTrashcan extends CustomDecorDataImpl { .soundGroup(SoundGroup.ANVIL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "III", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/Wheelbarrow.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/Wheelbarrow.java index 6370c113..dfbc0d80 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/Wheelbarrow.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/decoration/street/Wheelbarrow.java @@ -37,8 +37,8 @@ public final class Wheelbarrow extends CustomDecorDataImpl { .soundGroup(SoundGroup.ANVIL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "S S", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/Nightstand.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/Nightstand.java index 0e57b402..5b24be1b 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/Nightstand.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/Nightstand.java @@ -40,8 +40,8 @@ public abstract class Nightstand> extends CustomDec .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .group(SharedConstants.MSDECOR_NAMESPACE + ":nightstand") .category(CraftingBookCategory.BUILDING) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/Armchair.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/Armchair.java index f91a2f9c..63af85c4 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/Armchair.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/Armchair.java @@ -40,8 +40,8 @@ public abstract class Armchair> extends CustomDecor .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .group(SharedConstants.MSDECOR_NAMESPACE + ":armchair") .category(CraftingBookCategory.BUILDING) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/BarStool.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/BarStool.java index c41403bd..cd20149c 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/BarStool.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/BarStool.java @@ -38,8 +38,8 @@ public final class BarStool extends CustomDecorDataImpl { .soundGroup(SoundGroup.CHAIN) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "ILI", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/Chair.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/Chair.java index 1b43ec0a..6a1759a5 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/Chair.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/Chair.java @@ -40,8 +40,8 @@ public abstract class Chair> extends CustomDecorDat .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .group(SharedConstants.MSDECOR_NAMESPACE + ":chair") .category(CraftingBookCategory.BUILDING) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/CoolArmchair.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/CoolArmchair.java index ddcd8fd9..9253c4f1 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/CoolArmchair.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/CoolArmchair.java @@ -38,8 +38,8 @@ public final class CoolArmchair extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "L ", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/CoolChair.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/CoolChair.java index 7354e49c..f7afa93e 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/CoolChair.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/CoolChair.java @@ -38,8 +38,8 @@ public final class CoolChair extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOL) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "LLL", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/PaintableRockingChair.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/PaintableRockingChair.java index e7fbd1f8..62e17a84 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/PaintableRockingChair.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/PaintableRockingChair.java @@ -40,8 +40,8 @@ public abstract class PaintableRockingChair> extend .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .group(SharedConstants.MSDECOR_NAMESPACE + ":paintable_rocking_chair") .category(CraftingBookCategory.BUILDING) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/RockingChair.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/RockingChair.java index 861924d1..6c0ab802 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/RockingChair.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/RockingChair.java @@ -40,8 +40,8 @@ public abstract class RockingChair> extends CustomD .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .group(SharedConstants.MSDECOR_NAMESPACE + ":rocking_chair") .category(CraftingBookCategory.BUILDING) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/SmallArmchair.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/SmallArmchair.java index 7867bcdc..3b63f2ec 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/SmallArmchair.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/SmallArmchair.java @@ -40,8 +40,8 @@ public abstract class SmallArmchair> extends Custom .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .group(SharedConstants.MSDECOR_NAMESPACE + ":small_armchair") .category(CraftingBookCategory.BUILDING) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/SmallChair.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/SmallChair.java index c744c318..75ef70a9 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/SmallChair.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/chair/SmallChair.java @@ -40,8 +40,8 @@ public abstract class SmallChair> extends CustomDec .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .group(SharedConstants.MSDECOR_NAMESPACE + ":small_chair") .category(CraftingBookCategory.BUILDING) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/lamp/BigLamp.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/lamp/BigLamp.java index dc94a447..a0fdeca3 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/lamp/BigLamp.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/lamp/BigLamp.java @@ -42,8 +42,8 @@ public final class BigLamp extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "L", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/lamp/SmallLamp.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/lamp/SmallLamp.java index c3876971..d7718f0a 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/lamp/SmallLamp.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/lamp/SmallLamp.java @@ -38,8 +38,8 @@ public final class SmallLamp extends CustomDecorDataImpl { .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .category(CraftingBookCategory.BUILDING) .shape( "L", diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/table/BigTable.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/table/BigTable.java index b22e9a3b..2841f05a 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/table/BigTable.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/table/BigTable.java @@ -43,8 +43,8 @@ public abstract class BigTable> extends CustomDecor .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .group(SharedConstants.MSDECOR_NAMESPACE + ":big_table") .category(CraftingBookCategory.BUILDING) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/table/SmallTable.java b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/table/SmallTable.java index 7ab9b1b0..ad09b500 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/table/SmallTable.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/decor/furniture/table/SmallTable.java @@ -43,8 +43,8 @@ public abstract class SmallTable> extends CustomDec .soundGroup(SoundGroup.WOOD) .itemStack(itemStack) .recipes( - unused -> RecipeEntry.of( - RecipeBuilder.shapedBuilder() + unused -> RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .group(SharedConstants.MSDECOR_NAMESPACE + ":small_table") .category(CraftingBookCategory.BUILDING) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/AntiRadiationTextile.java b/src/main/java/com/minersstudios/mscustoms/registry/item/AntiRadiationTextile.java index c76f929b..1cf94025 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/AntiRadiationTextile.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/AntiRadiationTextile.java @@ -38,8 +38,8 @@ public AntiRadiationTextile() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/Cocaine.java b/src/main/java/com/minersstudios/mscustoms/registry/item/Cocaine.java index 5076e705..db8b688f 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/Cocaine.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/Cocaine.java @@ -51,8 +51,8 @@ public Cocaine() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/Dosimeter.java b/src/main/java/com/minersstudios/mscustoms/registry/item/Dosimeter.java index d60f18f2..95d5abbe 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/Dosimeter.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/Dosimeter.java @@ -42,8 +42,8 @@ public Dosimeter() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/PlumbumIngot.java b/src/main/java/com/minersstudios/mscustoms/registry/item/PlumbumIngot.java index 46332841..65051176 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/PlumbumIngot.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/PlumbumIngot.java @@ -44,14 +44,14 @@ public PlumbumIngot() { public @NotNull @Unmodifiable List initRecipes() { final ItemStack input = CustomItemType.RAW_PLUMBUM.getCustomItem().getItem(); final var furnaceBuilder = - RecipeBuilder.furnaceBuilder() + RecipeBuilder.furnace() .namespacedKey(new NamespacedKey(SharedConstants.MSITEMS_NAMESPACE, "plumbum_ingot_furnace")) .result(this.itemStack) .ingredient(new RecipeChoice.ExactChoice(input)) .experience(0.7f) .cookingTime(200); final var blastingBuilder = - RecipeBuilder.blastingBuilder() + RecipeBuilder.blasting() .namespacedKey(new NamespacedKey(SharedConstants.MSITEMS_NAMESPACE, "plumbum_ingot_blast")) .result(this.itemStack) .ingredient(new RecipeChoice.ExactChoice(input)) @@ -66,16 +66,16 @@ public PlumbumIngot() { ); return Arrays.asList( - RecipeEntry.of(furnaceBuilder), - RecipeEntry.of(blastingBuilder) + RecipeEntry.fromBuilder(furnaceBuilder), + RecipeEntry.fromBuilder(blastingBuilder) ); } return Arrays.asList( - RecipeEntry.of(furnaceBuilder), - RecipeEntry.of(blastingBuilder), - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder(furnaceBuilder), + RecipeEntry.fromBuilder(blastingBuilder), + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(new NamespacedKey(SharedConstants.MSITEMS_NAMESPACE, "plumbum_ingot_from_block")) .result(this.itemStack.clone().add(8)) .shape("I") diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/RawPlumbum.java b/src/main/java/com/minersstudios/mscustoms/registry/item/RawPlumbum.java index 0ce518ec..c4764df4 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/RawPlumbum.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/RawPlumbum.java @@ -42,7 +42,7 @@ public RawPlumbum() { @Override public @NotNull @Unmodifiable List initRecipes() { final var shapedBuilder = - RecipeBuilder.shapedBuilder() + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( @@ -62,13 +62,13 @@ public RawPlumbum() { "Can't find custom block with key: raw_plumbum_block! Shaped recipe for RawPlumbum will not be registered!" ); - return Collections.singletonList(RecipeEntry.of(shapedBuilder, true)); + return Collections.singletonList(RecipeEntry.fromBuilder(shapedBuilder, true)); } return Arrays.asList( - RecipeEntry.of(shapedBuilder, true), - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder(shapedBuilder, true), + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(new NamespacedKey(SharedConstants.MSITEMS_NAMESPACE, "raw_plumbum_from_block")) .result(this.itemStack.clone().add(8)) .shape("I") diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/Wrench.java b/src/main/java/com/minersstudios/mscustoms/registry/item/Wrench.java index f6b398a2..7c39534c 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/Wrench.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/Wrench.java @@ -48,8 +48,8 @@ public Wrench() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape("I", "I", "I") diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatBoots.java b/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatBoots.java index 4b475c1f..57962a81 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatBoots.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatBoots.java @@ -59,8 +59,8 @@ public HazmatBoots() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatChestplate.java b/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatChestplate.java index 5128f18d..178ca31f 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatChestplate.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatChestplate.java @@ -59,8 +59,8 @@ public HazmatChestplate() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatHelmet.java b/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatHelmet.java index bce20675..c367cbae 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatHelmet.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatHelmet.java @@ -59,8 +59,8 @@ public HazmatHelmet() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatLeggings.java b/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatLeggings.java index 91836be1..cfdc48b1 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatLeggings.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/armor/hazmat/HazmatLeggings.java @@ -59,8 +59,8 @@ public HazmatLeggings() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/cards/CardsBicycle.java b/src/main/java/com/minersstudios/mscustoms/registry/item/cards/CardsBicycle.java index ddadc6d6..64de9a6e 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/cards/CardsBicycle.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/cards/CardsBicycle.java @@ -153,8 +153,8 @@ public First() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( @@ -203,8 +203,8 @@ public Second() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( @@ -331,8 +331,8 @@ public First() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( @@ -379,8 +379,8 @@ public Second() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/registry/item/cosmetics/LeatherHat.java b/src/main/java/com/minersstudios/mscustoms/registry/item/cosmetics/LeatherHat.java index cc71c716..baa2f70a 100644 --- a/src/main/java/com/minersstudios/mscustoms/registry/item/cosmetics/LeatherHat.java +++ b/src/main/java/com/minersstudios/mscustoms/registry/item/cosmetics/LeatherHat.java @@ -48,8 +48,8 @@ public LeatherHat() { @Override public @NotNull @Unmodifiable List initRecipes() { return Collections.singletonList( - RecipeEntry.of( - RecipeBuilder.shapedBuilder() + RecipeEntry.fromBuilder( + RecipeBuilder.shaped() .namespacedKey(this.namespacedKey) .result(this.itemStack) .shape( diff --git a/src/main/java/com/minersstudios/mscustoms/sound/Sound.java b/src/main/java/com/minersstudios/mscustoms/sound/Sound.java index 0c1ae303..1959f87f 100644 --- a/src/main/java/com/minersstudios/mscustoms/sound/Sound.java +++ b/src/main/java/com/minersstudios/mscustoms/sound/Sound.java @@ -47,38 +47,53 @@ public interface Sound { /** + * Returns the key of this Sound + * * @return The key of this Sound */ @NotNull String getKey(); /** - * @return The sound category of this Sound + * Returns the sound category of this sound + * + * @return The sound category of this sound */ @NotNull SoundCategory getCategory(); /** - * @return The volume of this Sound + * Returns the volume of this sound + * + * @return The volume of this sound */ float getVolume(); /** - * @return The pitch of this Sound + * Returns the pitch of this sound + * + * @return The pitch of this sound */ float getPitch(); /** - * @return The hash code value for this sound. If this sound is empty, the - * hash code will be 0. + * Returns the hash code value for this sound. + *
+ * If this sound is empty, the hash code will be 0. + * + * @return The hash code value for this sound */ @Override int hashCode(); /** + * Returns whether this Sound is empty + * * @return True if this Sound is empty */ boolean isEmpty(); /** + * Returns whether this Sound is the same as the specified object + * * @param obj The reference object with which to compare * @return True if this Sound is the same as the obj argument */ @@ -87,13 +102,17 @@ public interface Sound { boolean equals(final @Nullable Object obj); /** + * Returns a string representation of this Sound + * * @return A string representation of this Sound */ @Override @NotNull String toString(); /** - * @return A builder with the values of this Sound + * Creates a new {@link Builder} with the values of this Sound + * + * @return A new builder with the values of this Sound */ @Contract(" -> new") @NotNull Builder toBuilder(); @@ -141,7 +160,7 @@ void play( ); /** - * Plays this Sound at the specified entity in the world. + * Plays this sound at the specified entity in the world. *
* If the place sound is {@link SoundGroup#WOOD}, the wood place sound from * the {@link Config} will be played instead. @@ -191,12 +210,12 @@ void play( * * @param key The key of the sound * @return A new Sound instance - * @throws IllegalArgumentException If the key is blank + * @throws IllegalStateException If the specified key is blank or null * @see #create(String, SoundCategory) * @see #create(String, SoundCategory, float, float) */ @Contract("_ -> new") - static @NotNull Sound create(final @NotNull String key) throws IllegalArgumentException { + static @NotNull Sound create(final @NotNull String key) throws IllegalStateException { return create( key, SoundCategory.MASTER @@ -228,14 +247,14 @@ void play( * @param key The key of the sound * @param soundCategory The sound category of the sound * @return A new Sound instance - * @throws IllegalArgumentException If the key is blank + * @throws IllegalStateException If the specified key is blank or null * @see #create(String, SoundCategory, float, float) */ @Contract("_, _ -> new") static @NotNull Sound create( final @NotNull String key, final @NotNull SoundCategory soundCategory - ) throws IllegalArgumentException { + ) throws IllegalStateException { return create( key, soundCategory, @@ -269,14 +288,14 @@ void play( } /** - * Creates a new Sound instance + * Creates a new {@link Sound} instance * * @param key The key of the sound * @param soundCategory The sound category of the sound * @param volume The volume of the sound * @param pitch The pitch of the sound * @return A new Sound instance - * @throws IllegalArgumentException If the key is blank + * @throws IllegalStateException If the specified key is blank or null */ @Contract("_, _, _, _ -> new") static @NotNull Sound create( @@ -284,7 +303,7 @@ void play( final @NotNull SoundCategory soundCategory, final float volume, final float pitch - ) throws IllegalArgumentException { + ) throws IllegalStateException { return builder() .key(key) .category(soundCategory) @@ -304,7 +323,9 @@ void play( } /** - * @return An empty Sound constant + * Returns an empty sound constant + * + * @return An empty sound constant */ static @NotNull Sound empty() { return EmptySound.SINGLETON; @@ -333,12 +354,14 @@ void play( interface Builder { /** - * @return The key of this Sound + * Returns the key of this sound + * + * @return The key of this sound, or null if not set */ @UnknownNullability String key(); /** - * Sets the key of this Sound + * Sets the key of this sound * * @param soundEvent The sound event, which will be converted to a key * @return This builder, for chaining @@ -348,7 +371,7 @@ interface Builder { @NotNull Builder key(final @NotNull SoundEvent soundEvent); /** - * Sets the key of this Sound + * Sets the key of this sound * * @param key The key to set * @return This builder, for chaining @@ -357,12 +380,14 @@ interface Builder { @NotNull Builder key(final @NotNull String key); /** - * @return The sound category of this Sound + * Returns the sound category of this sound + * + * @return The sound category of this sound, or null if not set */ @UnknownNullability SoundCategory category(); /** - * Sets the sound category of this Sound + * Sets the sound category of this sound * * @param category The sound category to set * @return This builder, for chaining @@ -371,12 +396,14 @@ interface Builder { @NotNull Builder category(final @NotNull SoundCategory category); /** - * @return The volume of this Sound + * Returns the volume of this sound + * + * @return The volume of this sound */ float volume(); /** - * Sets the volume of this Sound + * Sets the volume of this sound * * @param volume The volume to set * @return This builder, for chaining @@ -385,12 +412,14 @@ interface Builder { @NotNull Builder volume(final float volume); /** - * @return The pitch of this Sound + * Returns the pitch of this sound + * + * @return The pitch of this sound */ float pitch(); /** - * Sets the pitch of this Sound + * Sets the pitch of this sound * * @param pitch The pitch to set * @return This builder, for chaining @@ -399,15 +428,17 @@ interface Builder { @NotNull Builder pitch(final float pitch); /** - * Builds a Sound with the values of this builder + * Builds a {@code Sound} with the values of this builder * - * @return The built Sound + * @return The built {@code Sound} * @throws IllegalStateException If the key is blank or null */ @Contract(" -> new") @NotNull Sound build() throws IllegalStateException; /** + * Returns a string representation of this builder + * * @return A string representation of this builder */ @Override diff --git a/src/main/java/com/minersstudios/mscustoms/sound/SoundAdapter.java b/src/main/java/com/minersstudios/mscustoms/sound/SoundAdapter.java index 1850c295..a0902c76 100644 --- a/src/main/java/com/minersstudios/mscustoms/sound/SoundAdapter.java +++ b/src/main/java/com/minersstudios/mscustoms/sound/SoundAdapter.java @@ -29,20 +29,29 @@ * * * If sound is empty, then serialized output will be primitive string - * {@link #EMPTY_VALUE}. + * {@link #VALUE_EMPTY}. *
- * If json is primitive string {@link #EMPTY_VALUE}, then deserialized + * If json is primitive string {@link #VALUE_EMPTY}, then deserialized * sound will be empty. */ public final class SoundAdapter implements JsonSerializer, JsonDeserializer { private static final Map KEY_TO_CATEGORY_MAP; - // - public static final String KEY_KEY = "key"; - public static final String CATEGORY_KEY = "category"; - public static final String VOLUME_KEY = "volume"; - public static final String PITCH_KEY = "pitch"; - public static final String EMPTY_VALUE = "empty"; + // + /** Property name for a sound key */ + public static final String KEY_KEY = "key"; + + /** Property name for a sound category */ + public static final String KEY_CATEGORY = "category"; + + /** Property name for a sound volume */ + public static final String KEY_VOLUME = "volume"; + + /** Property name for a sound pitch */ + public static final String KEY_PITCH = "pitch"; + + /** Value for empty sound */ + public static final String VALUE_EMPTY = "empty"; // static { @@ -66,7 +75,7 @@ public final class SoundAdapter implements JsonSerializer, JsonDeserializ if (json.isJsonPrimitive()) { final String value = json.getAsString(); - if (EMPTY_VALUE.equals(value)) { + if (VALUE_EMPTY.equals(value)) { return Sound.empty(); } @@ -119,15 +128,15 @@ public final class SoundAdapter implements JsonSerializer, JsonDeserializ final @Nullable JsonSerializationContext context ) { if (sound.isEmpty()) { - return new JsonPrimitive(EMPTY_VALUE); + return new JsonPrimitive(VALUE_EMPTY); } final JsonObject jsonObject = new JsonObject(); jsonObject.addProperty(KEY_KEY, sound.getKey()); - jsonObject.addProperty(CATEGORY_KEY, sound.getCategory().name()); - jsonObject.addProperty(VOLUME_KEY, sound.getVolume()); - jsonObject.addProperty(PITCH_KEY, sound.getPitch()); + jsonObject.addProperty(KEY_CATEGORY, sound.getCategory().name()); + jsonObject.addProperty(KEY_VOLUME, sound.getVolume()); + jsonObject.addProperty(KEY_PITCH, sound.getPitch()); return jsonObject; } diff --git a/src/main/java/com/minersstudios/mscustoms/sound/SoundGroup.java b/src/main/java/com/minersstudios/mscustoms/sound/SoundGroup.java index ef872f64..65364584 100644 --- a/src/main/java/com/minersstudios/mscustoms/sound/SoundGroup.java +++ b/src/main/java/com/minersstudios/mscustoms/sound/SoundGroup.java @@ -37,6 +37,7 @@ * * @version 1.20.4 */ +@SuppressWarnings("unused") @Immutable public final class SoundGroup { private final Sound placeSound; @@ -157,14 +158,6 @@ public final class SoundGroup { public static final SoundGroup WET_SPONGE = create(SoundType.WET_SPONGE); // - /** - * Constructs a SoundGroup with the specified sounds - * - * @param placeSound The place sound - * @param breakSound The break sound - * @param hitSound The hit sound - * @param stepSound The step sound - */ private SoundGroup( final @NotNull Sound placeSound, final @NotNull Sound breakSound, diff --git a/src/main/java/com/minersstudios/msessentials/Config.java b/src/main/java/com/minersstudios/msessentials/Config.java index 98312155..27c6a197 100644 --- a/src/main/java/com/minersstudios/msessentials/Config.java +++ b/src/main/java/com/minersstudios/msessentials/Config.java @@ -39,9 +39,9 @@ * configuration. */ public final class Config extends PluginConfig { + private boolean developerMode; private long anomalyCheckRate; private long anomalyParticlesCheckRate; - private boolean developerMode; private long discordServerId; private long memberRoleId; private long discordGlobalChannelId; @@ -72,41 +72,99 @@ public final class Config extends PluginConfig { public static final String EXAMPLE_ANOMALY_FILE_PATH = ANOMALIES_FOLDER + '/' + EXAMPLE_ANOMALY_FILE_NAME; //
- /** - * Configuration constructor - * - * @param plugin The plugin that owns this config - */ + // + public static final String KEY_DEVELOPER_MODE = "developer-mode"; + public static final String KEY_ANOMALY_CHECK_RATE = "anomaly-check-rate"; + public static final String KEY_ANOMALY_PARTICLES_CHECK_RATE = "anomaly-particles-check-rate"; + + public static final String KEY_SKIN_SECTION = "skin"; + public static final String KEY_MINE_SKIN_API_KEY = "mine-skin-api-key"; + + public static final String KEY_DISCORD_SECTION = "discord"; + public static final String KEY_SERVER_ID = "server-id"; + public static final String KEY_MEMBER_ROLE_ID = "member-role-id"; + public static final String KEY_BOT_TOKEN = "bot-token"; + + public static final String KEY_CHAT_SECTION = "chat"; + public static final String KEY_LOCAL_SECTION = "local"; + public static final String KEY_GLOBAL_SECTION = "global"; + public static final String KEY_RADIUS = "radius"; + public static final String KEY_DISCORD_CHANNEL_ID = "discord-channel-id"; + + public static final String KEY_SPAWN_LOCATION_SECTION = "spawn-location"; + public static final String KEY_WORLD = "world"; + public static final String KEY_X = "x"; + public static final String KEY_Y = "y"; + public static final String KEY_Z = "z"; + public static final String KEY_YAW = "yaw"; + public static final String KEY_PITCH = "pitch"; + + public static final String KEY_RESOURCE_PACKS_SECTION = "resource-packs"; + // + + // + public static boolean DEFAULT_DEVELOPER_MODE = false; + public static long DEFAULT_ANOMALY_CHECK_RATE = 100L; + public static long DEFAULT_ANOMALY_PARTICLES_CHECK_RATE = 10L; + public static double DEFAULT_LOCAL_CHAT_RADIUS = 25.0d; + public static long DEFAULT_DISCORD_CHANNEL_ID = -1; + public static char DEFAULT_BOT_TOKEN = ' '; + public static long DEFAULT_SERVER_ID = -1; + public static long DEFAULT_MEMBER_ROLE_ID = -1; + public static char DEFAULT_MINE_SKIN_API_KEY = ' '; + // + Config(final @NotNull MSEssentials plugin) throws IllegalArgumentException { super(plugin, plugin.getConfigFile()); } - /** - * Reloads config variables - */ @Override public void reloadVariables() { final MSEssentials plugin = this.getPlugin(); final Cache cache = plugin.getCache(); - this.developerMode = this.yaml.getBoolean("developer-mode"); - this.anomalyCheckRate = this.yaml.getLong("anomaly-check-rate"); - this.anomalyParticlesCheckRate = this.yaml.getLong("anomaly-particles-check-rate"); - this.localChatRadius = this.yaml.getDouble("chat.local.radius"); - this.discordServerId = this.yaml.getLong("discord.server-id"); - this.memberRoleId = this.yaml.getLong("discord.member-role-id"); - this.discordGlobalChannelId = this.yaml.getLong("chat.global.discord-channel-id"); - this.discordLocalChannelId = this.yaml.getLong("chat.local.discord-channel-id"); - this.mineSkinApiKey = this.yaml.getString("skin.mine-skin-api-key"); + this.developerMode = this.yaml.getBoolean(KEY_DEVELOPER_MODE); + this.anomalyCheckRate = this.yaml.getLong(KEY_ANOMALY_CHECK_RATE); + this.anomalyParticlesCheckRate = this.yaml.getLong(KEY_ANOMALY_PARTICLES_CHECK_RATE); + + final ConfigurationSection chatSection = this.yaml.getConfigurationSection(KEY_CHAT_SECTION); + + if (chatSection != null) { + final ConfigurationSection localSection = chatSection.getConfigurationSection(KEY_LOCAL_SECTION); + + if (localSection != null) { + this.localChatRadius = localSection.getDouble(KEY_RADIUS); + this.discordLocalChannelId = localSection.getLong(KEY_DISCORD_CHANNEL_ID); + } + + final ConfigurationSection globalSection = chatSection.getConfigurationSection(KEY_GLOBAL_SECTION); + + if (globalSection != null) { + this.discordGlobalChannelId = globalSection.getLong(KEY_DISCORD_CHANNEL_ID); + } + } + + final ConfigurationSection discordSection = this.yaml.getConfigurationSection(KEY_DISCORD_SECTION); + + if (discordSection != null) { + this.discordServerId = discordSection.getLong(KEY_SERVER_ID); + this.memberRoleId = discordSection.getLong(KEY_MEMBER_ROLE_ID); + } + + final ConfigurationSection skinSection = this.yaml.getConfigurationSection(KEY_SKIN_SECTION); + + if (skinSection != null) { + this.mineSkinApiKey = skinSection.getString(KEY_MINE_SKIN_API_KEY); + } final Server server = plugin.getServer(); - final String spawnLocationWorldName = this.yaml.getString("spawn-location.world", ""); + final String spawnLocationWorldName = this.yaml.getString(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_WORLD, ""); final World spawnLocationWorld = server.getWorld(spawnLocationWorldName); - final double spawnLocationX = this.yaml.getDouble("spawn-location.x"); - final double spawnLocationY = this.yaml.getDouble("spawn-location.y"); - final double spawnLocationZ = this.yaml.getDouble("spawn-location.z"); - final float spawnLocationYaw = (float) this.yaml.getDouble("spawn-location.yaw"); - final float spawnLocationPitch = (float) this.yaml.getDouble("spawn-location.pitch"); + final double spawnLocationX = this.yaml.getDouble(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_X); + final double spawnLocationY = this.yaml.getDouble(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_Y); + final double spawnLocationZ = this.yaml.getDouble(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_Z); + final float spawnLocationYaw = (float) this.yaml.getDouble(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_YAW); + final float spawnLocationPitch = (float) this.yaml.getDouble(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_PITCH); if (spawnLocationWorld == null) { plugin.getLogger().warning("World \"" + spawnLocationWorldName + "\" not found!\nUsing default spawn location!"); @@ -150,30 +208,50 @@ public void reloadVariables() { cache.getDiscordManager().load(); } - /** - * Reloads default config variables - */ @Override public void reloadDefaultVariables() { - this.setIfNotExists("developer-mode", false); - this.setIfNotExists("anomaly-check-rate", 100L); - this.setIfNotExists("anomaly-particles-check-rate", 10L); - this.setIfNotExists("chat.local.radius", 25.0d); - this.setIfNotExists("chat.global.discord-channel-id", -1); - this.setIfNotExists("chat.local.discord-channel-id", -1); - this.setIfNotExists("discord.bot-token", ""); - this.setIfNotExists("discord.server-id", -1); - this.setIfNotExists("discord.member-role-id", -1); - this.setIfNotExists("skin.mine-skin-api-key", ""); + this.setIfNotExists(KEY_DEVELOPER_MODE, DEFAULT_DEVELOPER_MODE); + this.setIfNotExists(KEY_ANOMALY_CHECK_RATE, DEFAULT_ANOMALY_CHECK_RATE); + this.setIfNotExists(KEY_ANOMALY_PARTICLES_CHECK_RATE, DEFAULT_ANOMALY_PARTICLES_CHECK_RATE); + + this.setIfNotExists(KEY_CHAT_SECTION + '.' + KEY_LOCAL_SECTION + '.' + KEY_RADIUS, DEFAULT_LOCAL_CHAT_RADIUS); + this.setIfNotExists(KEY_CHAT_SECTION + '.' + KEY_LOCAL_SECTION + '.' + KEY_DISCORD_CHANNEL_ID, DEFAULT_DISCORD_CHANNEL_ID); + this.setIfNotExists(KEY_CHAT_SECTION + '.' + KEY_GLOBAL_SECTION + '.' + KEY_DISCORD_CHANNEL_ID, DEFAULT_DISCORD_CHANNEL_ID); + + this.setIfNotExists(KEY_DISCORD_SECTION + '.' + KEY_BOT_TOKEN, DEFAULT_BOT_TOKEN); + this.setIfNotExists(KEY_DISCORD_SECTION + '.' + KEY_SERVER_ID, DEFAULT_SERVER_ID); + this.setIfNotExists(KEY_DISCORD_SECTION + '.' + KEY_MEMBER_ROLE_ID, DEFAULT_MEMBER_ROLE_ID); + + this.setIfNotExists(KEY_SKIN_SECTION + '.' + KEY_MINE_SKIN_API_KEY, DEFAULT_MINE_SKIN_API_KEY); final Location mainWorldSpawn = Bukkit.getWorlds().get(0).getSpawnLocation(); - this.setIfNotExists("spawn-location.world", mainWorldSpawn.getWorld().getName()); - this.setIfNotExists("spawn-location.x", mainWorldSpawn.x()); - this.setIfNotExists("spawn-location.y", mainWorldSpawn.y()); - this.setIfNotExists("spawn-location.z", mainWorldSpawn.z()); - this.setIfNotExists("spawn-location.yaw", mainWorldSpawn.getYaw()); - this.setIfNotExists("spawn-location.pitch", mainWorldSpawn.getPitch()); + this.setIfNotExists(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_WORLD, mainWorldSpawn.getWorld().getName()); + this.setIfNotExists(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_X, mainWorldSpawn.x()); + this.setIfNotExists(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_Y, mainWorldSpawn.y()); + this.setIfNotExists(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_Z, mainWorldSpawn.z()); + this.setIfNotExists(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_YAW, mainWorldSpawn.getYaw()); + this.setIfNotExists(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_PITCH, mainWorldSpawn.getPitch()); + } + + /** + * @return True if developer mode is enabled + */ + public boolean isDeveloperMode() { + return this.developerMode; + } + + /** + * Sets developer mode state + * + * @param developerMode The new developer mode state + */ + public void setDeveloperMode(final boolean developerMode) { + this.developerMode = developerMode; + + this.yaml.set(KEY_DEVELOPER_MODE, developerMode); + + this.save(); } /** @@ -191,7 +269,7 @@ public long getAnomalyCheckRate() { public void setAnomalyCheckRate(final long rate) { this.anomalyCheckRate = rate; - this.yaml.set("anomaly-check-rate", rate); + this.yaml.set(KEY_ANOMALY_CHECK_RATE, rate); this.save(); } @@ -211,27 +289,7 @@ public long getAnomalyParticlesCheckRate() { public void setAnomalyParticlesCheckRate(final long rate) { this.anomalyParticlesCheckRate = rate; - this.yaml.set("anomaly-particles-check-rate", rate); - - this.save(); - } - - /** - * @return True if developer mode is enabled - */ - public boolean isDeveloperMode() { - return this.developerMode; - } - - /** - * Sets developer mode state - * - * @param developerMode The new developer mode state - */ - public void setDeveloperMode(final boolean developerMode) { - this.developerMode = developerMode; - - this.yaml.set("developer-mode", developerMode); + this.yaml.set(KEY_ANOMALY_PARTICLES_CHECK_RATE, rate); this.save(); } @@ -251,7 +309,7 @@ public long getDiscordServerId() { public void setDiscordServerId(final long id) { this.discordServerId = id; - this.yaml.set("discord.server-id", id); + this.yaml.set(KEY_DISCORD_SECTION + '.' + KEY_SERVER_ID, id); this.save(); } @@ -271,7 +329,7 @@ public long getMemberRoleId() { public void setMemberRoleId(final long id) { this.memberRoleId = id; - this.yaml.set("discord.member-role-id", id); + this.yaml.set(KEY_DISCORD_SECTION + '.' + KEY_MEMBER_ROLE_ID, id); this.save(); } @@ -291,7 +349,7 @@ public long getDiscordGlobalChannelId() { public void setDiscordGlobalChannelId(final long id) { this.discordGlobalChannelId = id; - this.yaml.set("chat.global.discord-channel-id", id); + this.yaml.set(KEY_CHAT_SECTION + '.' + KEY_GLOBAL_SECTION + '.' + KEY_DISCORD_CHANNEL_ID, id); this.save(); } @@ -311,7 +369,7 @@ public long getDiscordLocalChannelId() { public void setDiscordLocalChannelId(final long id) { this.discordLocalChannelId = id; - this.yaml.set("chat.local.discord-channel-id", id); + this.yaml.set(KEY_CHAT_SECTION + '.' + KEY_LOCAL_SECTION + '.' + KEY_DISCORD_CHANNEL_ID, id); this.save(); } @@ -331,7 +389,7 @@ public double getLocalChatRadius() { public void setLocalChatRadius(final double radius) { this.localChatRadius = radius; - this.yaml.set("chat.local.radius", radius); + this.yaml.set(KEY_CHAT_SECTION + '.' + KEY_LOCAL_SECTION + '.' + KEY_RADIUS, radius); this.save(); } @@ -351,7 +409,7 @@ public void setLocalChatRadius(final double radius) { public void setMineSkinApiKey(final @Nullable String apiKey) { this.mineSkinApiKey = apiKey; - this.yaml.set("skin.mine-skin-api-key", apiKey); + this.yaml.set(KEY_SKIN_SECTION + '.' + KEY_MINE_SKIN_API_KEY, apiKey); this.save(); } @@ -371,24 +429,24 @@ public void setMineSkinApiKey(final @Nullable String apiKey) { public void setSpawnLocation(final @NotNull Location location) { this.spawnLocation = location; - this.yaml.set("spawn-location.world", location.getWorld().getName()); - this.yaml.set("spawn-location.x", location.x()); - this.yaml.set("spawn-location.y", location.y()); - this.yaml.set("spawn-location.z", location.z()); - this.yaml.set("spawn-location.yaw", location.getYaw()); - this.yaml.set("spawn-location.pitch", location.getPitch()); + this.yaml.set(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_WORLD, location.getWorld().getName()); + this.yaml.set(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_X, location.x()); + this.yaml.set(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_Y, location.y()); + this.yaml.set(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_Z, location.z()); + this.yaml.set(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_YAW, location.getYaw()); + this.yaml.set(KEY_SPAWN_LOCATION_SECTION + '.' + KEY_PITCH, location.getPitch()); this.save(); } private void loadResourcePacks() { final MSEssentials plugin = this.getPlugin(); - final ConfigurationSection resourcePacksSection = this.yaml.getConfigurationSection("resource-packs"); + final ConfigurationSection resourcePacksSection = this.yaml.getConfigurationSection(KEY_RESOURCE_PACKS_SECTION); - plugin.setStatus(MSEssentials.LOADING_RESOURCE_PACKS); + plugin.assignStatus(MSEssentials.LOADING_RESOURCE_PACKS); if (resourcePacksSection == null) { - plugin.setStatus(MSEssentials.LOADED_RESOURCE_PACKS); + plugin.assignStatus(MSEssentials.LOADED_RESOURCE_PACKS); return; } @@ -426,7 +484,7 @@ private void loadResourcePacks() { } ); } catch (final FatalPackLoadException e) { - plugin.setStatus(MSEssentials.FAILED_LOAD_RESOURCE_PACKS); + plugin.assignStatus(MSEssentials.FAILED_LOAD_RESOURCE_PACKS); logger.error( "Failed to load resource packs due to a fatal error!", e @@ -442,7 +500,7 @@ private void loadResourcePacks() { .toArray(CompletableFuture[]::new) ) .thenRun( - () -> plugin.setStatus(MSEssentials.LOADED_RESOURCE_PACKS) + () -> plugin.assignStatus(MSEssentials.LOADED_RESOURCE_PACKS) ); } @@ -451,7 +509,7 @@ private void loadAnomalies() { final Cache cache = plugin.getCache(); final Logger logger = plugin.getLogger(); - plugin.setStatus(MSEssentials.LOADING_ANOMALIES); + plugin.assignStatus(MSEssentials.LOADING_ANOMALIES); try (final var path = Files.walk(Paths.get(this.file.getParent() + '/' + ANOMALIES_FOLDER))) { path.parallel() @@ -476,9 +534,9 @@ private void loadAnomalies() { } }); - plugin.setStatus(MSEssentials.LOADED_ANOMALIES); + plugin.assignStatus(MSEssentials.LOADED_ANOMALIES); } catch (final IOException e) { - plugin.setStatus(MSEssentials.FAILED_LOAD_ANOMALIES); + plugin.assignStatus(MSEssentials.FAILED_LOAD_ANOMALIES); logger.log( Level.SEVERE, "An error occurred while loading anomalies!", diff --git a/src/main/java/com/minersstudios/msessentials/MSEssentials.java b/src/main/java/com/minersstudios/msessentials/MSEssentials.java index 012f0c92..5880358d 100644 --- a/src/main/java/com/minersstudios/msessentials/MSEssentials.java +++ b/src/main/java/com/minersstudios/msessentials/MSEssentials.java @@ -1,9 +1,8 @@ package com.minersstudios.msessentials; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.plugin.MSPlugin; -import com.minersstudios.mscore.plugin.status.FailureStatus; -import com.minersstudios.mscore.plugin.status.SuccessStatus; +import com.minersstudios.mscore.status.FailureStatus; +import com.minersstudios.mscore.status.SuccessStatus; import com.minersstudios.mscore.utility.SharedConstants; import com.minersstudios.msessentials.chat.ChatType; import com.minersstudios.msessentials.discord.DiscordManager; @@ -25,9 +24,9 @@ import java.util.logging.Level; import java.util.logging.Logger; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.ON_DISABLE_MESSAGE_SUBTITLE; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.ON_DISABLE_MESSAGE_TITLE; -import static com.minersstudios.mscore.plugin.status.SuccessStatus.low; +import static com.minersstudios.mscore.locale.Translations.*; +import static com.minersstudios.mscore.status.Status.failureLow; +import static com.minersstudios.mscore.status.Status.successLow; /** * The main class of the MSEssentials plugin @@ -45,16 +44,16 @@ public final class MSEssentials extends MSPlugin { public static final String NAMESPACE = "msessentials"; // - public static final FailureStatus FAILED_LOAD_RESOURCE_PACKS = FailureStatus.low("FAILED_LOAD_RESOURCE_PACKS"); - public static final FailureStatus FAILED_LOAD_ANOMALIES = FailureStatus.low("FAILED_LOAD_ANOMALIES"); - public static final FailureStatus FAILED_LOAD_DISCORD = FailureStatus.low("FAILED_LOAD_DISCORD"); - - public static final SuccessStatus LOADING_RESOURCE_PACKS = low("LOADING_RESOURCE_PACKS"); - public static final SuccessStatus LOADED_RESOURCE_PACKS = low("LOADED_RESOURCE_PACKS", FAILED_LOAD_RESOURCE_PACKS); - public static final SuccessStatus LOADING_ANOMALIES = low("LOADING_ANOMALIES"); - public static final SuccessStatus LOADED_ANOMALIES = low("LOADED_ANOMALIES", FAILED_LOAD_ANOMALIES); - public static final SuccessStatus LOADING_DISCORD = low("LOADING_DISCORD"); - public static final SuccessStatus LOADED_DISCORD = low("LOADED_DISCORD", FAILED_LOAD_DISCORD); + public static final FailureStatus FAILED_LOAD_RESOURCE_PACKS = failureLow("FAILED_LOAD_RESOURCE_PACKS"); + public static final FailureStatus FAILED_LOAD_ANOMALIES = failureLow("FAILED_LOAD_ANOMALIES"); + public static final FailureStatus FAILED_LOAD_DISCORD = failureLow("FAILED_LOAD_DISCORD"); + + public static final SuccessStatus LOADING_RESOURCE_PACKS = successLow("LOADING_RESOURCE_PACKS"); + public static final SuccessStatus LOADED_RESOURCE_PACKS = successLow("LOADED_RESOURCE_PACKS", FAILED_LOAD_RESOURCE_PACKS); + public static final SuccessStatus LOADING_ANOMALIES = successLow("LOADING_ANOMALIES"); + public static final SuccessStatus LOADED_ANOMALIES = successLow("LOADED_ANOMALIES", FAILED_LOAD_ANOMALIES); + public static final SuccessStatus LOADING_DISCORD = successLow("LOADING_DISCORD"); + public static final SuccessStatus LOADED_DISCORD = successLow("LOADED_DISCORD", FAILED_LOAD_DISCORD); // @Override @@ -196,8 +195,8 @@ private void kickAll() { .get(player) .kick( player, - ON_DISABLE_MESSAGE_TITLE, - ON_DISABLE_MESSAGE_SUBTITLE, + ON_DISABLE_MESSAGE_TITLE.asTranslatable(), + ON_DISABLE_MESSAGE_SUBTITLE.asTranslatable(), PlayerKickEvent.Cause.RESTART_COMMAND ); } @@ -208,8 +207,8 @@ private void sendServerDisableMessage() { final DiscordManager discordManager = this.cache.getDiscordManager(); if (discordManager != null) { - discordManager.sendMessage(ChatType.GLOBAL, LanguageRegistry.Strings.DISCORD_SERVER_DISABLED); - discordManager.sendMessage(ChatType.LOCAL, LanguageRegistry.Strings.DISCORD_SERVER_DISABLED); + discordManager.sendMessage(ChatType.GLOBAL, DISCORD_SERVER_DISABLED.asString()); + discordManager.sendMessage(ChatType.LOCAL, DISCORD_SERVER_DISABLED.asString()); } } } diff --git a/src/main/java/com/minersstudios/msessentials/command/api/discord/SlashCommand.java b/src/main/java/com/minersstudios/msessentials/command/api/discord/SlashCommand.java index 6059411d..3701a022 100644 --- a/src/main/java/com/minersstudios/msessentials/command/api/discord/SlashCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/api/discord/SlashCommand.java @@ -1,9 +1,6 @@ package com.minersstudios.msessentials.command.api.discord; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * All discord slash commands annotated using {@link SlashCommand} will be @@ -12,6 +9,7 @@ * * @see SlashCommandExecutor */ +@Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface SlashCommand {} diff --git a/src/main/java/com/minersstudios/msessentials/command/api/discord/interaction/CommandHandler.java b/src/main/java/com/minersstudios/msessentials/command/api/discord/interaction/CommandHandler.java index 3d46a70c..8a145e34 100644 --- a/src/main/java/com/minersstudios/msessentials/command/api/discord/interaction/CommandHandler.java +++ b/src/main/java/com/minersstudios/msessentials/command/api/discord/interaction/CommandHandler.java @@ -1,6 +1,6 @@ package com.minersstudios.msessentials.command.api.discord.interaction; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.msessentials.MSEssentials; import com.minersstudios.msessentials.discord.BotHandler; import com.minersstudios.msessentials.player.PlayerInfo; @@ -34,7 +34,7 @@ public CommandHandler( final User user = this.getInteraction().getUser(); if (!this.getPlugin().getCache().getDiscordManager().isVerified(user)) { - this.send(LanguageRegistry.Strings.DISCORD_NOT_A_USER); + this.send(Translations.DISCORD_NOT_A_USER.asString()); return null; } @@ -42,7 +42,7 @@ public CommandHandler( final PlayerInfo playerInfo = PlayerInfo.fromDiscord(this.getPlugin(), user.getIdLong()); if (playerInfo == null) { - this.send(LanguageRegistry.Strings.DISCORD_NOT_LINKED); + this.send(Translations.DISCORD_NOT_LINKED.asString()); return null; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/discord/AddSkinCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/discord/AddSkinCommand.java index 1979033f..016607c2 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/discord/AddSkinCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/discord/AddSkinCommand.java @@ -1,10 +1,10 @@ package com.minersstudios.msessentials.command.impl.discord; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.plugin.MSLogger; -import com.minersstudios.msessentials.command.api.discord.interaction.CommandHandler; +import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.msessentials.command.api.discord.SlashCommand; import com.minersstudios.msessentials.command.api.discord.SlashCommandExecutor; +import com.minersstudios.msessentials.command.api.discord.interaction.CommandHandler; import com.minersstudios.msessentials.player.PlayerInfo; import com.minersstudios.msessentials.player.skin.Skin; import net.dv8tion.jda.api.interactions.commands.OptionMapping; @@ -14,8 +14,7 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import static com.minersstudios.mscore.language.LanguageFile.renderTranslation; -import static com.minersstudios.mscore.language.LanguageRegistry.Strings.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; @SlashCommand @@ -62,27 +61,29 @@ protected void onCommand(final @NotNull CommandHandler handler) { final OptionMapping nameOption = interaction.getOption("name"); if (nameOption == null) { - handler.send(DISCORD_SKIN_INVALID_NAME_REGEX); + handler.send(DISCORD_SKIN_INVALID_NAME_REGEX.asString()); return; } final String name = nameOption.getAsString(); if (!Skin.matchesNameRegex(name)) { - handler.send(DISCORD_SKIN_INVALID_NAME_REGEX); + handler.send(DISCORD_SKIN_INVALID_NAME_REGEX.asString()); + return; } if (playerInfo.getPlayerFile().containsSkin(name)) { handler.send( - renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_ALREADY_SET - .arguments( + ChatUtils.serializePlainComponent( + DISCORD_SKIN_ALREADY_SET + .asComponent( playerInfo.getDefaultName(), text(playerInfo.getNickname()) ) ) ); + return; } @@ -99,12 +100,12 @@ protected void onCommand(final @NotNull CommandHandler handler) { final Skin skin = Skin.create(this.getPlugin(), name, urlOption.getAsString()); if (skin == null) { - handler.send(DISCORD_SKIN_SERVICE_UNAVAILABLE); + handler.send(DISCORD_SKIN_SERVICE_UNAVAILABLE.asString()); } else { addSkin(handler, playerInfo, skin); } } catch (final IllegalArgumentException ignored) { - handler.send(DISCORD_SKIN_INVALID_IMG); + handler.send(DISCORD_SKIN_INVALID_IMG.asString()); } } else if ( urlOption == null @@ -122,10 +123,10 @@ protected void onCommand(final @NotNull CommandHandler handler) { ) ); } catch (final IllegalArgumentException ignored) { - handler.send(DISCORD_SKIN_INVALID_IMG); + handler.send(DISCORD_SKIN_INVALID_IMG.asString()); } } else { - handler.send(DISCORD_COMMAND_INVALID_ARGUMENTS); + handler.send(DISCORD_COMMAND_INVALID_ARGUMENTS.asString()); } } @@ -139,9 +140,9 @@ private static void addSkin( playerInfo.getPlayerFile().addSkin(skin); handler.sendEmbed( - renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_ADDED - .arguments( + ChatUtils.serializePlainComponent( + DISCORD_SKIN_SUCCESSFULLY_ADDED + .asComponent( text(skinName), playerInfo.getDefaultName(), text(playerInfo.getNickname()) @@ -152,7 +153,7 @@ private static void addSkin( if (onlinePlayer != null) { MSLogger.fine( onlinePlayer, - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT.arguments(text(skinName)) + DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT.asTranslatable().arguments(text(skinName)) ); } } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/discord/EditSkinCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/discord/EditSkinCommand.java index da1321dc..dbf2a93d 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/discord/EditSkinCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/discord/EditSkinCommand.java @@ -1,7 +1,7 @@ package com.minersstudios.msessentials.command.impl.discord; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.plugin.MSLogger; +import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.msessentials.command.api.discord.SlashCommand; import com.minersstudios.msessentials.command.api.discord.SlashCommandExecutor; import com.minersstudios.msessentials.command.api.discord.interaction.CommandHandler; @@ -24,8 +24,7 @@ import java.util.List; -import static com.minersstudios.mscore.language.LanguageFile.renderTranslation; -import static com.minersstudios.mscore.language.LanguageRegistry.Strings.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; @SlashCommand @@ -55,14 +54,14 @@ protected void onCommand(final @NotNull CommandHandler handler) { final OptionMapping nameOption = interaction.getOption("name"); if (nameOption == null) { - handler.send(DISCORD_SKIN_INVALID_NAME_REGEX); + handler.send(DISCORD_SKIN_INVALID_NAME_REGEX.asString()); return; } final String name = nameOption.getAsString(); if (!Skin.matchesNameRegex(name)) { - handler.send(DISCORD_SKIN_INVALID_NAME_REGEX); + handler.send(DISCORD_SKIN_INVALID_NAME_REGEX.asString()); return; } @@ -70,9 +69,9 @@ protected void onCommand(final @NotNull CommandHandler handler) { if (skinIndex == -1) { handler.send( - renderTranslation( - LanguageRegistry.Components.DISCORD_COMMAND_SKIN_NOT_FOUND - .arguments(text(name)) + ChatUtils.serializePlainComponent( + DISCORD_COMMAND_SKIN_NOT_FOUND + .asComponent(text(name)) ) ); } @@ -90,12 +89,12 @@ protected void onCommand(final @NotNull CommandHandler handler) { final Skin skin = Skin.create(this.getPlugin(), name, urlOption.getAsString()); if (skin == null) { - handler.send(DISCORD_SKIN_SERVICE_UNAVAILABLE); + handler.send(DISCORD_SKIN_SERVICE_UNAVAILABLE.asString()); } else { edit(playerInfo, skinIndex, skin, null, handler); } } catch (final IllegalArgumentException ignored) { - handler.send(DISCORD_SKIN_INVALID_IMG); + handler.send(DISCORD_SKIN_INVALID_IMG.asString()); } } else if ( urlOption == null @@ -115,10 +114,10 @@ protected void onCommand(final @NotNull CommandHandler handler) { handler ); } catch (final IllegalArgumentException ignored) { - handler.send(DISCORD_SKIN_INVALID_IMG); + handler.send(DISCORD_SKIN_INVALID_IMG.asString()); } } else { - handler.send(DISCORD_COMMAND_INVALID_ARGUMENTS); + handler.send(DISCORD_COMMAND_INVALID_ARGUMENTS.asString()); } } @@ -165,9 +164,9 @@ public static boolean edit( final Player player = playerInfo.getOnlinePlayer(); final MessageEmbed embed = BotHandler.craftEmbed( - renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_EDITED - .arguments( + ChatUtils.serializePlainComponent( + DISCORD_SKIN_SUCCESSFULLY_EDITED + .asComponent( text(skinName), playerInfo.getDefaultName(), text(playerInfo.getNickname()) @@ -178,7 +177,7 @@ public static boolean edit( if (player != null) { MSLogger.fine( player, - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_EDITED_MINECRAFT + DISCORD_SKIN_SUCCESSFULLY_EDITED_MINECRAFT.asTranslatable() .arguments(text(skinName)) ); } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/discord/RemoveSkinCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/discord/RemoveSkinCommand.java index 50fd9081..973a7600 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/discord/RemoveSkinCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/discord/RemoveSkinCommand.java @@ -1,7 +1,7 @@ package com.minersstudios.msessentials.command.impl.discord; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.plugin.MSLogger; +import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.msessentials.command.api.discord.SlashCommand; import com.minersstudios.msessentials.command.api.discord.SlashCommandExecutor; import com.minersstudios.msessentials.command.api.discord.interaction.CommandHandler; @@ -23,8 +23,7 @@ import java.util.List; -import static com.minersstudios.mscore.language.LanguageFile.renderTranslation; -import static com.minersstudios.mscore.language.LanguageRegistry.Strings.DISCORD_SKIN_INVALID_NAME_REGEX; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; @SlashCommand @@ -51,14 +50,16 @@ public void onCommand(final @NotNull CommandHandler handler) { final OptionMapping nameOption = interaction.getOption("name"); if (nameOption == null) { - handler.send(DISCORD_SKIN_INVALID_NAME_REGEX); + handler.send(DISCORD_SKIN_INVALID_NAME_REGEX.asString()); + return; } final String name = nameOption.getAsString(); if (!Skin.matchesNameRegex(name)) { - handler.send(DISCORD_SKIN_INVALID_NAME_REGEX); + handler.send(DISCORD_SKIN_INVALID_NAME_REGEX.asString()); + return; } @@ -69,9 +70,9 @@ public void onCommand(final @NotNull CommandHandler handler) { || !remove(playerInfo, skin, null, handler) ) { handler.send( - renderTranslation( - LanguageRegistry.Components.DISCORD_COMMAND_SKIN_NOT_FOUND - .arguments(text(name)) + ChatUtils.serializePlainComponent( + DISCORD_COMMAND_SKIN_NOT_FOUND + .asComponent(text(name)) ) ); } @@ -119,9 +120,9 @@ public static boolean remove( final Player player = playerInfo.getOnlinePlayer(); final MessageEmbed embed = BotHandler.craftEmbed( - renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_REMOVED - .arguments( + ChatUtils.serializePlainComponent( + DISCORD_SKIN_SUCCESSFULLY_REMOVED + .asComponent( text(skinName), playerInfo.getDefaultName(), text(playerInfo.getNickname()) @@ -132,7 +133,7 @@ public static boolean remove( if (player != null) { MSLogger.fine( player, - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT + DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT.asTranslatable() .arguments(text(skinName)) ); } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/discord/SkinListCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/discord/SkinListCommand.java index 98a10f21..23ca3632 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/discord/SkinListCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/discord/SkinListCommand.java @@ -1,17 +1,14 @@ package com.minersstudios.msessentials.command.impl.discord; -import com.minersstudios.mscore.language.LanguageFile; -import com.minersstudios.msessentials.command.api.discord.interaction.CommandHandler; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.msessentials.command.api.discord.SlashCommand; import com.minersstudios.msessentials.command.api.discord.SlashCommandExecutor; +import com.minersstudios.msessentials.command.api.discord.interaction.CommandHandler; import com.minersstudios.msessentials.discord.BotHandler; import com.minersstudios.msessentials.player.PlayerInfo; import net.dv8tion.jda.api.interactions.commands.build.Commands; import org.jetbrains.annotations.NotNull; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.DISCORD_COMMAND_LIST_OF_SKINS; -import static net.kyori.adventure.text.Component.text; - @SlashCommand public final class SkinListCommand extends SlashCommandExecutor { @@ -39,10 +36,8 @@ public void onCommand(final @NotNull CommandHandler handler) { handler.send( BotHandler.craftEmbed( - LanguageFile.renderTranslation( - DISCORD_COMMAND_LIST_OF_SKINS - .arguments(text(skinList.toString())) - ) + Translations.DISCORD_COMMAND_LIST_OF_SKINS + .asString(skinList.toString()) ) ); } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/discord/UnlinkCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/discord/UnlinkCommand.java index 35f0c164..7726960d 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/discord/UnlinkCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/discord/UnlinkCommand.java @@ -1,18 +1,18 @@ package com.minersstudios.msessentials.command.impl.discord; -import com.minersstudios.mscore.language.LanguageFile; import com.minersstudios.mscore.plugin.MSLogger; -import com.minersstudios.msessentials.command.api.discord.interaction.CommandHandler; +import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.msessentials.command.api.discord.SlashCommand; import com.minersstudios.msessentials.command.api.discord.SlashCommandExecutor; +import com.minersstudios.msessentials.command.api.discord.interaction.CommandHandler; import com.minersstudios.msessentials.discord.BotHandler; import com.minersstudios.msessentials.player.PlayerInfo; import net.dv8tion.jda.api.interactions.commands.build.Commands; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS; +import static com.minersstudios.mscore.locale.Translations.COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS; +import static com.minersstudios.mscore.locale.Translations.COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS; import static net.kyori.adventure.text.Component.text; @SlashCommand @@ -34,12 +34,10 @@ public void onCommand(final @NotNull CommandHandler handler) { playerInfo.unlinkDiscord(); handler.send( BotHandler.craftEmbed( - LanguageFile.renderTranslation( - COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS - .arguments( - playerInfo.getDefaultName(), - text(playerInfo.getPlayerFile().getPlayerName().getNickname()) - ) + COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS + .asString( + ChatUtils.serializePlainComponent(playerInfo.getDefaultName()), + playerInfo.getPlayerFile().getPlayerName().getNickname() ) ) ); @@ -49,7 +47,7 @@ public void onCommand(final @NotNull CommandHandler handler) { if (onlinePlayer != null) { MSLogger.fine( onlinePlayer, - COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS + COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS.asTranslatable() .arguments(text(handler.getInteraction().getUser().getName())) ); } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/GetMapLocationCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/GetMapLocationCommand.java index f6ac115e..aef535f8 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/GetMapLocationCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/GetMapLocationCommand.java @@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; @MSCommand( @@ -46,7 +46,7 @@ public boolean onCommand( if (!(player.getInventory().getItemInMainHand().getItemMeta() instanceof final MapMeta mapMeta)) { MSLogger.warning( player, - COMMAND_GET_MAP_LOCATION_NO_MAP_IN_RIGHT_HAND + COMMAND_GET_MAP_LOCATION_NO_MAP_IN_RIGHT_HAND.asTranslatable() ); return true; @@ -60,8 +60,9 @@ public boolean onCommand( ) { MSLogger.severe( sender, - ERROR_SOMETHING_WENT_WRONG + ERROR_SOMETHING_WENT_WRONG.asTranslatable() ); + return true; } @@ -71,13 +72,13 @@ public boolean onCommand( MSLogger.warning( player, - COMMAND_GET_MAP_LOCATION_FORMAT + COMMAND_GET_MAP_LOCATION_FORMAT.asTranslatable() .arguments( text(mapView.getWorld().getName(), NamedTextColor.WHITE), text(x, NamedTextColor.WHITE), text(y, NamedTextColor.WHITE), text(z, NamedTextColor.WHITE), - COMMAND_GET_MAP_LOCATION_COMMAND_BUTTON_TEXT + COMMAND_GET_MAP_LOCATION_COMMAND_BUTTON_TEXT.asTranslatable() .decorate(TextDecoration.BOLD) .clickEvent(ClickEvent.runCommand("/tp " + x + " " + y + " " + z)) ) diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/KickCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/KickCommand.java index 67fbfa47..3e7170f3 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/KickCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/KickCommand.java @@ -21,7 +21,7 @@ import java.util.List; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument; import static net.kyori.adventure.text.Component.text; @@ -54,15 +54,15 @@ public boolean onCommand( final Component reason = args.length > 1 ? text(ChatUtils.extractMessage(args, 1)) - : COMMAND_KICK_DEFAULT_REASON; - + : COMMAND_KICK_DEFAULT_REASON.asTranslatable(); final PlayerInfo playerInfo = PlayerInfo.fromString(this.getPlugin(), args[0]); if (playerInfo == null) { MSLogger.severe( sender, - ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } @@ -71,20 +71,21 @@ public boolean onCommand( if (player == null) { MSLogger.warning( sender, - ERROR_PLAYER_NOT_ONLINE + ERROR_PLAYER_NOT_ONLINE.asTranslatable() ); + return true; } playerInfo.kick( - COMMAND_KICK_MESSAGE_RECEIVER_TITLE, - COMMAND_KICK_MESSAGE_RECEIVER_SUBTITLE + COMMAND_KICK_MESSAGE_RECEIVER_TITLE.asTranslatable(), + COMMAND_KICK_MESSAGE_RECEIVER_SUBTITLE.asTranslatable() .arguments(reason), PlayerKickEvent.Cause.KICK_COMMAND ); MSLogger.fine( sender, - COMMAND_KICK_MESSAGE_SENDER + COMMAND_KICK_MESSAGE_SENDER.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/SetServerSpawn.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/SetServerSpawn.java index 2c8a5d30..92dcb43b 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/SetServerSpawn.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/SetServerSpawn.java @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.List; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument; import static net.kyori.adventure.text.Component.text; @@ -66,8 +66,9 @@ public boolean onCommand( if (!(sender instanceof final Player player)) { MSLogger.warning( sender, - ERROR_ONLY_PLAYER_COMMAND + ERROR_ONLY_PLAYER_COMMAND.asTranslatable() ); + return true; } @@ -79,8 +80,9 @@ public boolean onCommand( if (world == null) { MSLogger.warning( sender, - COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND + COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND.asTranslatable() ); + return true; } @@ -92,8 +94,9 @@ public boolean onCommand( if (world == null) { MSLogger.warning( sender, - COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND + COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND.asTranslatable() ); + return true; } @@ -115,8 +118,9 @@ public boolean onCommand( ) { MSLogger.warning( sender, - COMMAND_SET_SERVER_SPAWN_TOO_BIG_COORDINATES + COMMAND_SET_SERVER_SPAWN_TOO_BIG_COORDINATES.asTranslatable() ); + return true; } @@ -128,8 +132,9 @@ public boolean onCommand( if (world == null) { MSLogger.warning( sender, - COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND + COMMAND_SET_SERVER_SPAWN_WORLD_NOT_FOUND.asTranslatable() ); + return true; } @@ -148,8 +153,9 @@ public boolean onCommand( if (x > 29999984 || z > 29999984) { MSLogger.warning( sender, - COMMAND_SET_SERVER_SPAWN_TOO_BIG_COORDINATES + COMMAND_SET_SERVER_SPAWN_TOO_BIG_COORDINATES.asTranslatable() ); + return true; } @@ -251,7 +257,7 @@ private static void setNewLocation( config.setSpawnLocation(location); MSLogger.fine( sender, - COMMAND_SET_SERVER_SPAWN_SUCCESSFULLY_SET + COMMAND_SET_SERVER_SPAWN_SUCCESSFULLY_SET.asTranslatable() .arguments( text(location.getWorld().getName()), text(String.valueOf(location.x())), diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/WhitelistCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/WhitelistCommand.java index 3546d3fd..79d2b849 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/WhitelistCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/WhitelistCommand.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.List; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument; import static net.kyori.adventure.text.Component.text; @@ -67,7 +67,7 @@ public boolean onCommand( server.reloadWhitelist(); MSLogger.fine( sender, - COMMAND_WHITE_LIST_RELOAD + COMMAND_WHITE_LIST_RELOAD.asTranslatable() ); return true; @@ -82,26 +82,28 @@ public boolean onCommand( if (playerInfo == null) { MSLogger.severe( sender, - ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } if (playerInfo.setWhiteListed(true)) { MSLogger.fine( sender, - COMMAND_WHITE_LIST_ADD_SENDER_MESSAGE + COMMAND_WHITE_LIST_ADD_SENDER_MESSAGE.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()) ) ); + return true; } MSLogger.warning( sender, - COMMAND_WHITE_LIST_ADD_ALREADY + COMMAND_WHITE_LIST_ADD_ALREADY.asTranslatable() .arguments( playerInfo.getGrayIDGoldName(), text(playerInfo.getNickname()) @@ -120,26 +122,28 @@ public boolean onCommand( if (playerInfo == null) { MSLogger.severe( sender, - ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } if (playerInfo.setWhiteListed(false)) { MSLogger.fine( sender, - COMMAND_WHITE_LIST_REMOVE_SENDER_MESSAGE + COMMAND_WHITE_LIST_REMOVE_SENDER_MESSAGE.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()) ) ); + return true; } MSLogger.warning( sender, - COMMAND_WHITE_LIST_REMOVE_NOT_FOUND + COMMAND_WHITE_LIST_REMOVE_NOT_FOUND.asTranslatable() .arguments( playerInfo.getGrayIDGoldName(), text(playerArg) diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/ban/BanCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/ban/BanCommand.java index 79a00970..2b36d18a 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/ban/BanCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/ban/BanCommand.java @@ -2,7 +2,6 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.DateUtils; @@ -22,8 +21,7 @@ import java.util.List; import java.util.UUID; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.ERROR_PLAYER_NOT_FOUND; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.ERROR_WRONG_FORMAT; +import static com.minersstudios.mscore.locale.Translations.*; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument; @@ -61,21 +59,21 @@ public boolean onCommand( if (date == null) { MSLogger.severe( sender, - ERROR_WRONG_FORMAT + ERROR_WRONG_FORMAT.asTranslatable() ); return true; } final String reason = args.length > 2 ? ChatUtils.extractMessage(args, 2) - : LanguageRegistry.Strings.COMMAND_BAN_DEFAULT_REASON; + : COMMAND_BAN_DEFAULT_REASON.asString(); final PlayerInfo playerInfo = PlayerInfo.fromString(this.getPlugin(), args[0]); if (playerInfo == null) { MSLogger.severe( sender, - ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/ban/UnBanCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/ban/UnBanCommand.java index b6697689..75bf7354 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/ban/UnBanCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/ban/UnBanCommand.java @@ -3,7 +3,7 @@ import com.destroystokyo.paper.profile.PlayerProfile; import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.Font; import com.minersstudios.msessentials.MSEssentials; @@ -59,8 +59,9 @@ public boolean onCommand( if (playerInfo == null) { MSLogger.severe( sender, - LanguageRegistry.Components.ERROR_PLAYER_NOT_FOUND + Translations.ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/ReloadCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/ReloadCommand.java index fd4f806a..f8d22f55 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/ReloadCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/ReloadCommand.java @@ -1,6 +1,6 @@ package com.minersstudios.msessentials.command.impl.minecraft.admin.msessentials; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.msessentials.MSEssentials; import org.bukkit.command.CommandSender; @@ -21,7 +21,7 @@ public static boolean runCommand( plugin.getConfiguration().reload(); MSLogger.fine( sender, - LanguageRegistry.Components.COMMAND_MSESSENTIALS_RELOAD_SUCCESS + Translations.COMMAND_MSESSENTIALS_RELOAD_SUCCESS.asTranslatable() .arguments(text(System.currentTimeMillis() - time)) ); diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/UpdateIdsCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/UpdateIdsCommand.java index c959eb15..95198cb6 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/UpdateIdsCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/UpdateIdsCommand.java @@ -1,6 +1,6 @@ package com.minersstudios.msessentials.command.impl.minecraft.admin.msessentials; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.msessentials.Cache; import com.minersstudios.msessentials.MSEssentials; @@ -23,7 +23,7 @@ public static boolean runCommand( cache.getPlayerInfoMap().playerInfos().forEach(PlayerInfo::initNames); MSLogger.fine( sender, - LanguageRegistry.Components.COMMAND_MSESSENTIALS_UPDATE_IDS_SUCCESS + Translations.COMMAND_MSESSENTIALS_UPDATE_IDS_SUCCESS.asTranslatable() .arguments(text(System.currentTimeMillis() - time)) ); diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/UpdateMutesCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/UpdateMutesCommand.java index 14008d3a..0f5ec0ac 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/UpdateMutesCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/msessentials/UpdateMutesCommand.java @@ -1,6 +1,6 @@ package com.minersstudios.msessentials.command.impl.minecraft.admin.msessentials; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.msessentials.MSEssentials; import org.bukkit.command.CommandSender; @@ -19,7 +19,7 @@ public static boolean runCommand( plugin.getCache().getMuteMap().reloadMutes(); MSLogger.fine( sender, - LanguageRegistry.Components.COMMAND_MSESSENTIALS_UPDATE_MUTES_SUCCESS + Translations.COMMAND_MSESSENTIALS_UPDATE_MUTES_SUCCESS.asTranslatable() .arguments(text(System.currentTimeMillis() - time)) ); diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/mute/MuteCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/mute/MuteCommand.java index a10e80f2..d32f1b4e 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/mute/MuteCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/mute/MuteCommand.java @@ -2,7 +2,6 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.DateUtils; @@ -25,8 +24,7 @@ import java.util.List; import java.util.UUID; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.ERROR_PLAYER_NOT_FOUND; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.ERROR_WRONG_FORMAT; +import static com.minersstudios.mscore.locale.Translations.*; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument; @@ -64,22 +62,24 @@ public boolean onCommand( if (date == null) { MSLogger.severe( sender, - ERROR_WRONG_FORMAT + ERROR_WRONG_FORMAT.asTranslatable() ); + return true; } final String reason = args.length > 2 ? ChatUtils.extractMessage(args, 2) - : LanguageRegistry.Strings.COMMAND_MUTE_DEFAULT_REASON; + : COMMAND_MUTE_DEFAULT_REASON.asString(); final PlayerInfo playerInfo = PlayerInfo.fromString(this.getPlugin(), args[0]); if (playerInfo == null) { MSLogger.severe( sender, - ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/mute/UnMuteCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/mute/UnMuteCommand.java index 4e849bda..d4ac4e59 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/mute/UnMuteCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/mute/UnMuteCommand.java @@ -2,7 +2,7 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.DateUtils; import com.minersstudios.mscore.utility.Font; @@ -56,8 +56,9 @@ public boolean onCommand( if (playerInfo == null) { MSLogger.severe( sender, - LanguageRegistry.Strings.ERROR_PLAYER_NOT_FOUND + Translations.ERROR_PLAYER_NOT_FOUND.asString() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminBanInfoCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminBanInfoCommand.java index 1264c32d..bd267337 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminBanInfoCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminBanInfoCommand.java @@ -13,7 +13,7 @@ import java.util.Date; import java.util.Locale; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; public final class AdminBanInfoCommand { @@ -32,7 +32,8 @@ public static boolean runCommand( MSLogger.fine( sender, banned - ? COMMAND_PLAYER_BAN_INFO_INFO.arguments( + ? COMMAND_PLAYER_BAN_INFO_INFO.asTranslatable() + .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(playerInfo.getBannedBy()), @@ -40,23 +41,26 @@ public static boolean runCommand( playerInfo.getBannedFrom(sender), playerInfo.getBannedTo(sender) ) - : COMMAND_PLAYER_BAN_INFO_NOT_BANNED.arguments( + : COMMAND_PLAYER_BAN_INFO_NOT_BANNED.asTranslatable() + .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()) ) ); + return true; } if (!banned) { MSLogger.severe( sender, - COMMAND_PLAYER_BAN_INFO_NOT_BANNED + COMMAND_PLAYER_BAN_INFO_NOT_BANNED.asTranslatable() .arguments( playerInfo.getDefaultName(), text(playerInfo.getNickname()) ) ); + return true; } @@ -65,13 +69,14 @@ public static boolean runCommand( if (!haveArg) { MSLogger.fine( sender, - COMMAND_PLAYER_BAN_INFO_GET_REASON + COMMAND_PLAYER_BAN_INFO_GET_REASON.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), playerInfo.getBanReason() ) ); + return true; } @@ -80,26 +85,28 @@ public static boolean runCommand( playerInfo.setBanReason(reason); MSLogger.fine( sender, - COMMAND_PLAYER_BAN_INFO_SET_REASON + COMMAND_PLAYER_BAN_INFO_SET_REASON.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(reason) ) ); + return true; } case "time" -> { if (!haveArg) { MSLogger.fine( sender, - COMMAND_PLAYER_BAN_INFO_GET_TIME_TO + COMMAND_PLAYER_BAN_INFO_GET_TIME_TO.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), playerInfo.getBannedTo(sender) ) ); + return true; } @@ -108,8 +115,9 @@ public static boolean runCommand( if (instant == null) { MSLogger.severe( sender, - ERROR_WRONG_FORMAT + ERROR_WRONG_FORMAT.asTranslatable() ); + return true; } @@ -126,16 +134,18 @@ public static boolean runCommand( MSLogger.fine( sender, - COMMAND_PLAYER_BAN_INFO_SET_TIME_TO + COMMAND_PLAYER_BAN_INFO_SET_TIME_TO.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(DateUtils.getSenderDate(instant, sender)) ) ); + return true; } } + return false; } } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminFirstJoinCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminFirstJoinCommand.java index d84dd095..5fa4f96a 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminFirstJoinCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminFirstJoinCommand.java @@ -1,6 +1,6 @@ package com.minersstudios.msessentials.command.impl.minecraft.admin.player; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.DateUtils; import com.minersstudios.msessentials.player.PlayerInfo; @@ -17,7 +17,7 @@ public static boolean runCommand( ) { MSLogger.fine( sender, - LanguageRegistry.Components.COMMAND_PLAYER_FIRST_JOIN + Translations.COMMAND_PLAYER_FIRST_JOIN.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminGameParamsCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminGameParamsCommand.java index 39888bf3..4552d1e8 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminGameParamsCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminGameParamsCommand.java @@ -10,7 +10,7 @@ import java.util.Locale; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; public final class AdminGameParamsCommand { @@ -23,7 +23,7 @@ public static boolean runCommand( if (args.length < 3) { MSLogger.severe( sender, - COMMAND_PLAYER_GAME_PARAMS_USE_ONE_OF + COMMAND_PLAYER_GAME_PARAMS_USE_ONE_OF.asTranslatable() ); return true; } @@ -40,12 +40,14 @@ public static boolean runCommand( MSLogger.fine( sender, player == null - ? COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE.arguments( + ? COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE.asTranslatable() + .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(playerFile.getGameMode().name().toLowerCase(Locale.ROOT)) ) - : COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE_FULL.arguments( + : COMMAND_PLAYER_GAME_PARAMS_GET_GAME_MODE_FULL.asTranslatable() + .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(playerFile.getGameMode().name().toLowerCase(Locale.ROOT)), @@ -61,7 +63,7 @@ public static boolean runCommand( } catch (final IllegalArgumentException ignore) { MSLogger.severe( sender, - COMMAND_PLAYER_GAME_PARAMS_GAME_MODE_USE_ONE_OF + COMMAND_PLAYER_GAME_PARAMS_GAME_MODE_USE_ONE_OF.asTranslatable() ); return true; } @@ -74,7 +76,7 @@ public static boolean runCommand( playerFile.save(); MSLogger.fine( sender, - COMMAND_PLAYER_GAME_PARAMS_SET_GAME_MODE + COMMAND_PLAYER_GAME_PARAMS_SET_GAME_MODE.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), @@ -88,18 +90,21 @@ public static boolean runCommand( MSLogger.fine( sender, player == null - ? COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH.arguments( + ? COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH.asTranslatable() + .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(Double.toString(playerFile.getHealth())) ) - : COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH_FULL.arguments( + : COMMAND_PLAYER_GAME_PARAMS_GET_HEALTH_FULL.asTranslatable() + .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(Double.toString(playerFile.getHealth())), text(Double.toString(player.getHealth())) ) ); + return true; } @@ -109,8 +114,9 @@ public static boolean runCommand( } catch (final NumberFormatException ignore) { MSLogger.severe( sender, - ERROR_WRONG_FORMAT + ERROR_WRONG_FORMAT.asTranslatable() ); + return true; } @@ -122,13 +128,14 @@ public static boolean runCommand( playerFile.save(); MSLogger.fine( sender, - COMMAND_PLAYER_GAME_PARAMS_SET_HEALTH + COMMAND_PLAYER_GAME_PARAMS_SET_HEALTH.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(paramArgString) ) ); + return true; } case "air" -> { @@ -136,18 +143,21 @@ public static boolean runCommand( MSLogger.fine( sender, player == null - ? COMMAND_PLAYER_GAME_PARAMS_GET_AIR.arguments( + ? COMMAND_PLAYER_GAME_PARAMS_GET_AIR.asTranslatable() + .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(playerFile.getAir()) ) - : COMMAND_PLAYER_GAME_PARAMS_GET_AIR_FULL.arguments( + : COMMAND_PLAYER_GAME_PARAMS_GET_AIR_FULL.asTranslatable() + .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(playerFile.getAir()), text(player.getRemainingAir()) ) ); + return true; } @@ -157,8 +167,9 @@ public static boolean runCommand( } catch (final NumberFormatException ignore) { MSLogger.severe( sender, - ERROR_WRONG_FORMAT + ERROR_WRONG_FORMAT.asTranslatable() ); + return true; } @@ -170,13 +181,14 @@ public static boolean runCommand( playerFile.save(); MSLogger.fine( sender, - COMMAND_PLAYER_GAME_PARAMS_SET_AIR + COMMAND_PLAYER_GAME_PARAMS_SET_AIR.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(paramArgString) ) ); + return true; } } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminMuteInfoCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminMuteInfoCommand.java index f03353b4..dd7cabdc 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminMuteInfoCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminMuteInfoCommand.java @@ -12,7 +12,7 @@ import java.time.Instant; import java.util.Locale; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; public final class AdminMuteInfoCommand { @@ -32,7 +32,8 @@ public static boolean runCommand( MSLogger.fine( sender, muted - ? COMMAND_PLAYER_MUTE_INFO_INFO.arguments( + ? COMMAND_PLAYER_MUTE_INFO_INFO.asTranslatable() + .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(playerInfo.getMutedBy()), @@ -40,7 +41,8 @@ public static boolean runCommand( playerInfo.getMutedFrom(sender), playerInfo.getMutedTo(sender) ) - : COMMAND_PLAYER_MUTE_INFO_INFO_NOT_MUTED.arguments( + : COMMAND_PLAYER_MUTE_INFO_INFO_NOT_MUTED.asTranslatable() + .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()) ) @@ -51,7 +53,7 @@ public static boolean runCommand( if (!muted) { MSLogger.severe( sender, - COMMAND_PLAYER_MUTE_INFO_NOT_MUTED + COMMAND_PLAYER_MUTE_INFO_NOT_MUTED.asTranslatable() .arguments( playerInfo.getDefaultName(), text(playerInfo.getNickname()) @@ -67,7 +69,7 @@ public static boolean runCommand( if (!haveArg) { MSLogger.fine( sender, - COMMAND_PLAYER_MUTE_INFO_GET_REASON + COMMAND_PLAYER_MUTE_INFO_GET_REASON.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), @@ -82,7 +84,7 @@ public static boolean runCommand( muteMap.put(playerInfo.getOfflinePlayer(), playerInfo.getMutedTo(), reason, sender.getName()); MSLogger.fine( sender, - COMMAND_PLAYER_MUTE_INFO_SET_REASON + COMMAND_PLAYER_MUTE_INFO_SET_REASON.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), @@ -95,7 +97,7 @@ public static boolean runCommand( if (!haveArg) { MSLogger.fine( sender, - COMMAND_PLAYER_MUTE_INFO_GET_TIME_TO + COMMAND_PLAYER_MUTE_INFO_GET_TIME_TO.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), @@ -110,7 +112,7 @@ public static boolean runCommand( if (instant == null) { MSLogger.severe( sender, - ERROR_WRONG_FORMAT + ERROR_WRONG_FORMAT.asTranslatable() ); return true; } @@ -118,7 +120,7 @@ public static boolean runCommand( muteMap.put(playerInfo.getOfflinePlayer(), instant, playerInfo.getMuteReason(), sender.getName()); MSLogger.fine( sender, - COMMAND_PLAYER_MUTE_INFO_SET_TIME_TO + COMMAND_PLAYER_MUTE_INFO_SET_TIME_TO.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminNameCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminNameCommand.java index 120f1781..b837e07e 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminNameCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminNameCommand.java @@ -12,7 +12,7 @@ import java.util.Locale; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; public final class AdminNameCommand { @@ -33,7 +33,7 @@ public static boolean runCommand( if (args.length == 2) { MSLogger.fine( sender, - COMMAND_PLAYER_NAME_ABOUT + COMMAND_PLAYER_NAME_ABOUT.asTranslatable() .arguments( playerInfo.getGrayIDGreenName() .appendSpace() @@ -42,6 +42,7 @@ public static boolean runCommand( text(playerInfo.getUuid().toString()) ) ); + return true; } @@ -52,8 +53,9 @@ public static boolean runCommand( ) { MSLogger.severe( sender, - ERROR_WRONG_FORMAT + ERROR_WRONG_FORMAT.asTranslatable() ); + return true; } @@ -65,7 +67,7 @@ public static boolean runCommand( MSLogger.fine( sender, - COMMAND_PLAYER_NAME_FULL_RESET_SENDER + COMMAND_PLAYER_NAME_FULL_RESET_SENDER.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()) @@ -79,8 +81,8 @@ public static boolean runCommand( playerFile.save(); playerInfo.initNames(); playerInfo.kick( - COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_TITLE, - COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_SUBTITLE + COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_TITLE.asTranslatable(), + COMMAND_PLAYER_NAME_FULL_RESET_RECEIVER_SUBTITLE.asTranslatable() ); return true; @@ -89,9 +91,10 @@ public static boolean runCommand( if (!haveArg) { MSLogger.fine( sender, - COMMAND_PLAYER_NAME_GET_FIRST_NAME + COMMAND_PLAYER_NAME_GET_FIRST_NAME.asTranslatable() .arguments(text(playerName.getFirstName())) ); + return true; } @@ -101,9 +104,10 @@ public static boolean runCommand( if (!haveArg) { MSLogger.fine( sender, - COMMAND_PLAYER_NAME_GET_LAST_NAME + COMMAND_PLAYER_NAME_GET_LAST_NAME.asTranslatable() .arguments(text(playerName.getLastName())) ); + return true; } @@ -113,9 +117,10 @@ public static boolean runCommand( if (!haveArg) { MSLogger.fine( sender, - COMMAND_PLAYER_NAME_GET_PATRONYMIC + COMMAND_PLAYER_NAME_GET_PATRONYMIC.asTranslatable() .arguments(text(playerName.getPatronymic())) ); + return true; } @@ -128,7 +133,7 @@ public static boolean runCommand( playerInfo.initNames(); MSLogger.fine( sender, - COMMAND_PLAYER_NAME_NOW_FULL + COMMAND_PLAYER_NAME_NOW_FULL.asTranslatable() .arguments( playerInfo.getGrayIDGreenName() .appendSpace() diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminPlayerCommandHandler.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminPlayerCommandHandler.java index 47b95b17..7eb515e5 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminPlayerCommandHandler.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminPlayerCommandHandler.java @@ -2,7 +2,6 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.DateUtils; import com.minersstudios.mscore.utility.Font; @@ -26,6 +25,7 @@ import java.util.Collections; import java.util.List; +import static com.minersstudios.mscore.locale.Translations.*; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument; @@ -96,8 +96,8 @@ public final class AdminPlayerCommandHandler extends AbstractCommandExecutor TAB_4_BAN_INFO_REASON = Collections.singletonList(LanguageRegistry.Strings.COMMAND_BAN_DEFAULT_REASON); - private final List TAB_4_MUTE_INFO_REASON = Collections.singletonList(LanguageRegistry.Strings.COMMAND_MUTE_DEFAULT_REASON); + private final List TAB_4_BAN_INFO_REASON = Collections.singletonList(COMMAND_BAN_DEFAULT_REASON.asString()); + private final List TAB_4_MUTE_INFO_REASON = Collections.singletonList(COMMAND_MUTE_DEFAULT_REASON.asString()); private static final List TAB_4_NAME_EMPTY = Collections.singletonList("empty"); private static final CommandNode COMMAND_NODE = literal("player") @@ -217,8 +217,9 @@ public boolean onCommand( if (playerInfo == null) { MSLogger.severe( sender, - LanguageRegistry.Components.ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminPronounsCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminPronounsCommand.java index 1a17b572..cafe144b 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminPronounsCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminPronounsCommand.java @@ -10,7 +10,7 @@ import java.util.Arrays; import java.util.Locale; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; public final class AdminPronounsCommand { @@ -25,30 +25,32 @@ public static boolean runCommand( if (args.length == 2) { MSLogger.fine( sender, - COMMAND_PLAYER_PRONOUNS_GET + COMMAND_PLAYER_PRONOUNS_GET.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(playerFile.getPronouns().name().toLowerCase(Locale.ROOT)) ) ); + return true; } else if (args.length == 3) { final String pronounsString = args[2]; - final Pronouns pronouns; + try { pronouns = Pronouns.valueOf(pronounsString.toUpperCase(Locale.ROOT)); } catch (final IllegalArgumentException ignore) { MSLogger.severe( sender, - COMMAND_PLAYER_PRONOUNS_USE_ONE_OF + COMMAND_PLAYER_PRONOUNS_USE_ONE_OF.asTranslatable() .arguments(text( Arrays.toString(Pronouns.values()) .toLowerCase() .replaceAll("[\\[\\]]", "") )) ); + return true; } @@ -56,7 +58,7 @@ public static boolean runCommand( playerFile.save(); MSLogger.fine( sender, - COMMAND_PLAYER_PRONOUNS_SET + COMMAND_PLAYER_PRONOUNS_SET.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminSettingsCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminSettingsCommand.java index 0cffcb47..729be669 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminSettingsCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminSettingsCommand.java @@ -1,13 +1,13 @@ package com.minersstudios.msessentials.command.impl.minecraft.admin.player; -import com.minersstudios.mscore.language.LanguageFile; import com.minersstudios.mscore.plugin.MSLogger; +import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.msessentials.MSEssentials; import com.minersstudios.msessentials.discord.BotHandler; -import com.minersstudios.msessentials.player.ResourcePack; import com.minersstudios.msessentials.player.PlayerFile; import com.minersstudios.msessentials.player.PlayerInfo; import com.minersstudios.msessentials.player.PlayerSettings; +import com.minersstudios.msessentials.player.ResourcePack; import com.minersstudios.msessentials.player.skin.Skin; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -16,7 +16,7 @@ import java.util.Arrays; import java.util.Locale; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; public final class AdminSettingsCommand { @@ -30,8 +30,9 @@ public static boolean runCommand( if (args.length < 3) { MSLogger.severe( sender, - COMMAND_PLAYER_SETTINGS_USE_ONE_OF + COMMAND_PLAYER_SETTINGS_USE_ONE_OF.asTranslatable() ); + return true; } @@ -47,13 +48,14 @@ public static boolean runCommand( if (!haveArg) { MSLogger.fine( sender, - COMMAND_PLAYER_SETTINGS_GET_RESOURCEPACK_TYPE + COMMAND_PLAYER_SETTINGS_GET_RESOURCEPACK_TYPE.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), text(playerSettings.getResourcePackType().name().toLowerCase(Locale.ROOT)) ) ); + return true; } @@ -68,7 +70,7 @@ public static boolean runCommand( if (type == null) { MSLogger.severe( sender, - COMMAND_PLAYER_SETTINGS_RESOURCEPACK_TYPE_USE_ONE_OF + COMMAND_PLAYER_SETTINGS_RESOURCEPACK_TYPE_USE_ONE_OF.asTranslatable() .arguments( text( Arrays.toString(ResourcePack.Type.values()) @@ -77,6 +79,7 @@ public static boolean runCommand( ) ) ); + return true; } @@ -85,14 +88,14 @@ public static boolean runCommand( if (type == ResourcePack.Type.NONE || type == ResourcePack.Type.NULL) { playerInfo.kick( - MENU_RESOURCE_PACK_BUTTON_NONE_KICK_TITLE, - MENU_RESOURCE_PACK_BUTTON_NONE_KICK_SUBTITLE + MENU_RESOURCE_PACK_BUTTON_NONE_KICK_TITLE.asTranslatable(), + MENU_RESOURCE_PACK_BUTTON_NONE_KICK_SUBTITLE.asTranslatable() ); } MSLogger.fine( sender, - COMMAND_PLAYER_SETTINGS_SET_RESOURCEPACK_TYPE + COMMAND_PLAYER_SETTINGS_SET_RESOURCEPACK_TYPE.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), @@ -109,7 +112,7 @@ public static boolean runCommand( if (skin == null) { MSLogger.warning( sender, - COMMAND_PLAYER_SETTINGS_GET_NO_SKIN + COMMAND_PLAYER_SETTINGS_GET_NO_SKIN.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()) @@ -118,7 +121,7 @@ public static boolean runCommand( } else { MSLogger.fine( sender, - COMMAND_PLAYER_SETTINGS_GET_SKIN + COMMAND_PLAYER_SETTINGS_GET_SKIN.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), @@ -142,7 +145,7 @@ public static boolean runCommand( if (skin == null) { MSLogger.severe( sender, - COMMAND_PLAYER_SETTINGS_SKIN_NOT_FOUND + COMMAND_PLAYER_SETTINGS_SKIN_NOT_FOUND.asTranslatable() .arguments(text(skinName)) ); } else { @@ -150,7 +153,7 @@ public static boolean runCommand( playerInfo.setSkin(skin); MSLogger.fine( sender, - COMMAND_PLAYER_SETTINGS_SET_SKIN + COMMAND_PLAYER_SETTINGS_SET_SKIN.asTranslatable() .arguments( playerInfo.getDefaultName(), text(playerInfo.getNickname()), @@ -161,7 +164,7 @@ public static boolean runCommand( playerFile.removeSkin(skin); MSLogger.fine( sender, - COMMAND_PLAYER_SETTINGS_REMOVE_SKIN + COMMAND_PLAYER_SETTINGS_REMOVE_SKIN.asTranslatable() .arguments( text(skinName), playerInfo.getDefaultName(), @@ -172,15 +175,15 @@ public static boolean runCommand( if (player != null) { MSLogger.fine( player, - DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT + DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT.asTranslatable() .arguments(text(skinName)) ); } playerInfo.sendPrivateDiscordMessage(BotHandler.craftEmbed( - LanguageFile.renderTranslation( + ChatUtils.serializePlainComponent( DISCORD_SKIN_SUCCESSFULLY_REMOVED - .arguments( + .asComponent( text(skinName), playerInfo.getDefaultName(), text(playerInfo.getNickname()) @@ -211,7 +214,7 @@ public static boolean runCommand( playerFile.addSkin(skin); MSLogger.fine( sender, - COMMAND_PLAYER_SETTINGS_ADD_SKIN + COMMAND_PLAYER_SETTINGS_ADD_SKIN.asTranslatable() .arguments( text(skinName), playerInfo.getDefaultName(), @@ -222,15 +225,15 @@ public static boolean runCommand( if (player != null) { MSLogger.fine( player, - DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT + DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT.asTranslatable() .arguments(text(skinName)) ); } playerInfo.sendPrivateDiscordMessage(BotHandler.craftEmbed( - LanguageFile.renderTranslation( + ChatUtils.serializePlainComponent( DISCORD_SKIN_SUCCESSFULLY_ADDED - .arguments( + .asComponent( text(skinName), playerInfo.getDefaultName(), text(playerInfo.getNickname()) @@ -247,7 +250,7 @@ public static boolean runCommand( MSLogger.severe( sender, - COMMAND_PLAYER_SETTINGS_ADD_SKIN_ERROR + COMMAND_PLAYER_SETTINGS_ADD_SKIN_ERROR.asTranslatable() .arguments( text(skinName), playerInfo.getDefaultName(), @@ -260,8 +263,9 @@ public static boolean runCommand( default -> { MSLogger.severe( sender, - COMMAND_PLAYER_SETTINGS_SKIN_USE_ONE_OF + COMMAND_PLAYER_SETTINGS_SKIN_USE_ONE_OF.asTranslatable() ); + return true; } } @@ -269,8 +273,9 @@ public static boolean runCommand( default -> { MSLogger.severe( sender, - COMMAND_PLAYER_SETTINGS_USE_ONE_OF + COMMAND_PLAYER_SETTINGS_USE_ONE_OF.asTranslatable() ); + return true; } } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminUpdateCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminUpdateCommand.java index d8d6af2f..1422111f 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminUpdateCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/player/AdminUpdateCommand.java @@ -1,6 +1,6 @@ package com.minersstudios.msessentials.command.impl.minecraft.admin.player; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.msessentials.player.PlayerInfo; import org.bukkit.command.CommandSender; @@ -17,7 +17,7 @@ public static boolean runCommand( playerInfo.update(); MSLogger.fine( sender, - LanguageRegistry.Components.COMMAND_PLAYER_UPDATE_SUCCESS + Translations.COMMAND_PLAYER_UPDATE_SUCCESS.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()) diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/teleport/TeleportToLastDeathLocationCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/teleport/TeleportToLastDeathLocationCommand.java index 17fd23c7..3fd4b542 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/teleport/TeleportToLastDeathLocationCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/teleport/TeleportToLastDeathLocationCommand.java @@ -17,7 +17,7 @@ import java.util.List; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument; import static net.kyori.adventure.text.Component.text; @@ -57,23 +57,25 @@ public boolean onCommand( if (playerInfo == null) { MSLogger.severe( sender, - ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } if (playerInfo.getOnlinePlayer() == null) { MSLogger.warning( sender, - ERROR_PLAYER_NOT_ONLINE + ERROR_PLAYER_NOT_ONLINE.asTranslatable() ); + return true; } playerInfo.teleportToLastDeathLocation().thenRun(() -> MSLogger.fine( sender, - COMMAND_TELEPORT_TO_LAST_DEATH_SENDER_MESSAGE + COMMAND_TELEPORT_TO_LAST_DEATH_SENDER_MESSAGE.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()) diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/teleport/WorldTeleportCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/teleport/WorldTeleportCommand.java index 9bb48288..54f05404 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/teleport/WorldTeleportCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/admin/teleport/WorldTeleportCommand.java @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.List; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument; import static net.kyori.adventure.text.Component.text; @@ -71,8 +71,9 @@ public boolean onCommand( if (playerInfo == null) { MSLogger.severe( sender, - ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } @@ -81,8 +82,9 @@ public boolean onCommand( if (player == null) { MSLogger.severe( sender, - ERROR_PLAYER_NOT_FOUND + ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } @@ -91,8 +93,9 @@ public boolean onCommand( if (world == null) { MSLogger.severe( sender, - COMMAND_WORLD_TELEPORT_WORLD_NOT_FOUND + COMMAND_WORLD_TELEPORT_WORLD_NOT_FOUND.asTranslatable() ); + return true; } @@ -115,8 +118,9 @@ public boolean onCommand( ) { MSLogger.severe( sender, - COMMAND_WORLD_TELEPORT_TOO_BIG_COORDINATES + COMMAND_WORLD_TELEPORT_TOO_BIG_COORDINATES.asTranslatable() ); + return true; } } else { @@ -130,7 +134,7 @@ public boolean onCommand( .thenRun( () -> MSLogger.fine( sender, - COMMAND_WORLD_TELEPORT_SENDER_MESSAGE + COMMAND_WORLD_TELEPORT_SENDER_MESSAGE.asTranslatable() .arguments( playerInfo.getGrayIDGreenName(), text(playerInfo.getNickname()), diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/DiscordCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/DiscordCommand.java index fc400025..4c895aa6 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/DiscordCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/DiscordCommand.java @@ -2,8 +2,8 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageFile; import com.minersstudios.mscore.plugin.MSLogger; +import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.Font; import com.minersstudios.msessentials.MSEssentials; import com.minersstudios.msessentials.discord.BotHandler; @@ -24,7 +24,7 @@ import java.util.Arrays; import java.util.List; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static com.minersstudios.mscore.utility.SharedConstants.DISCORD_LINK; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; import static net.kyori.adventure.text.Component.text; @@ -46,13 +46,13 @@ public final class DiscordCommand extends AbstractCommandExecutor .build(); private static final TranslatableComponent DISCORD_MESSAGE = - COMMAND_DISCORD + COMMAND_DISCORD.asTranslatable() .arguments( text(DISCORD_LINK) - .hoverEvent(showText(LINK_HOVER.color(NamedTextColor.GRAY))) + .hoverEvent(showText(COMMAND_HOVER_SUGGEST.asTranslatable().color(NamedTextColor.GRAY))) .clickEvent(ClickEvent.openUrl(DISCORD_LINK)), text("/discord link") - .hoverEvent(showText(COMMAND_HOVER_RUN.color(NamedTextColor.GRAY))) + .hoverEvent(showText(COMMAND_HOVER_RUN.asTranslatable().color(NamedTextColor.GRAY))) .clickEvent(ClickEvent.runCommand("/discord link")) ); @@ -76,8 +76,9 @@ public boolean onCommand( if (id == -1L) { MSLogger.warning( sender, - COMMAND_DISCORD_UNLINK_NO_LINKS + COMMAND_DISCORD_UNLINK_NO_LINKS.asTranslatable() ); + return true; } @@ -88,9 +89,9 @@ public boolean onCommand( discordManager.sendEmbeds( user, BotHandler.craftEmbed( - LanguageFile.renderTranslation( + ChatUtils.serializePlainComponent( COMMAND_DISCORD_UNLINK_DISCORD_SUCCESS - .arguments( + .asComponent( playerInfo.getDefaultName(), text(player.getName()) ) @@ -99,7 +100,7 @@ public boolean onCommand( ); MSLogger.fine( player, - COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS + COMMAND_DISCORD_UNLINK_MINECRAFT_SUCCESS.asTranslatable() .arguments(text(user.getName())) ); }); diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/PrivateMessageCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/PrivateMessageCommand.java index 502505aa..818f4cb5 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/PrivateMessageCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/PrivateMessageCommand.java @@ -2,7 +2,7 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.Font; @@ -64,8 +64,9 @@ public boolean onCommand( if (senderInfo.isMuted()) { MSLogger.warning( sender, - LanguageRegistry.Components.COMMAND_MUTE_ALREADY_RECEIVER + Translations.COMMAND_MUTE_ALREADY_RECEIVER.asTranslatable() ); + return true; } @@ -74,8 +75,9 @@ public boolean onCommand( if (receiverInfo == null) { MSLogger.warning( sender, - LanguageRegistry.Components.ERROR_PLAYER_NOT_FOUND + Translations.ERROR_PLAYER_NOT_FOUND.asTranslatable() ); + return true; } @@ -85,8 +87,9 @@ public boolean onCommand( ) { MSLogger.warning( sender, - LanguageRegistry.Components.ERROR_PLAYER_NOT_ONLINE + Translations.ERROR_PLAYER_NOT_ONLINE.asTranslatable() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/DoCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/DoCommand.java index 3d6bf9c7..c2e0da7b 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/DoCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/DoCommand.java @@ -2,7 +2,7 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.Font; @@ -51,8 +51,9 @@ public boolean onCommand( if (playerInfo.isMuted()) { MSLogger.warning( player, - LanguageRegistry.Components.COMMAND_MUTE_ALREADY_RECEIVER + Translations.COMMAND_MUTE_ALREADY_RECEIVER.asTranslatable() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/FartCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/FartCommand.java index bfdb18a9..80b91b2e 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/FartCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/FartCommand.java @@ -2,7 +2,7 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.location.MSPosition; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.BlockUtils; @@ -57,8 +57,9 @@ public boolean onCommand( if (playerInfo.isMuted()) { MSLogger.warning( player, - LanguageRegistry.Components.COMMAND_MUTE_ALREADY_RECEIVER + Translations.COMMAND_MUTE_ALREADY_RECEIVER.asTranslatable() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/ItCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/ItCommand.java index 61a4eb60..d23cd3c5 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/ItCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/ItCommand.java @@ -2,7 +2,7 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.Font; @@ -51,8 +51,9 @@ public boolean onCommand( if (playerInfo.isMuted()) { MSLogger.warning( player, - LanguageRegistry.Components.COMMAND_MUTE_ALREADY_RECEIVER + Translations.COMMAND_MUTE_ALREADY_RECEIVER.asTranslatable() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/MeCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/MeCommand.java index def6d7c4..074b9b8a 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/MeCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/MeCommand.java @@ -2,7 +2,7 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.Font; @@ -51,8 +51,9 @@ public boolean onCommand( if (playerInfo.isMuted()) { MSLogger.warning( player, - LanguageRegistry.Components.COMMAND_MUTE_ALREADY_RECEIVER + Translations.COMMAND_MUTE_ALREADY_RECEIVER.asTranslatable() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/SitCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/SitCommand.java index e390e31a..bb8c371f 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/SitCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/SitCommand.java @@ -2,7 +2,7 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.Font; @@ -47,8 +47,9 @@ public boolean onCommand( if (!player.getLocation().subtract(0.0d, 0.2d, 0.0d).getBlock().getType().isSolid()) { MSLogger.warning( player, - LanguageRegistry.Components.COMMAND_SIT_IN_AIR + Translations.COMMAND_SIT_IN_AIR.asTranslatable() ); + return true; } @@ -61,8 +62,9 @@ public boolean onCommand( ) { MSLogger.warning( player, - LanguageRegistry.Components.COMMAND_MUTE_ALREADY_RECEIVER + Translations.COMMAND_MUTE_ALREADY_RECEIVER.asTranslatable() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/SpitCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/SpitCommand.java index b5247856..c8102dc9 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/SpitCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/SpitCommand.java @@ -2,7 +2,7 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.Font; @@ -55,8 +55,9 @@ public boolean onCommand( if (playerInfo.isMuted()) { MSLogger.warning( player, - LanguageRegistry.Components.COMMAND_MUTE_ALREADY_RECEIVER + Translations.COMMAND_MUTE_ALREADY_RECEIVER.asTranslatable() ); + return true; } @@ -68,10 +69,12 @@ public boolean onCommand( if (args.length > 0) { sendRPEventMessage(player, text(ChatUtils.extractMessage(args, 0)), text("плюнув"), TODO); + return true; } sendRPEventMessage(player, playerInfo.getPlayerFile().getPronouns().getSpitMessage(), ME); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/TodoCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/TodoCommand.java index 6cca75a8..a9556f60 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/TodoCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/TodoCommand.java @@ -2,7 +2,7 @@ import com.minersstudios.mscore.command.api.AbstractCommandExecutor; import com.minersstudios.mscore.command.api.MSCommand; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.Font; @@ -61,8 +61,9 @@ public boolean onCommand( if (playerInfo.isMuted()) { MSLogger.warning( player, - LanguageRegistry.Components.COMMAND_MUTE_ALREADY_RECEIVER + Translations.COMMAND_MUTE_ALREADY_RECEIVER.asTranslatable() ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/TryCommand.java b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/TryCommand.java index a48fe022..8da99bbc 100644 --- a/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/TryCommand.java +++ b/src/main/java/com/minersstudios/msessentials/command/impl/minecraft/player/roleplay/TryCommand.java @@ -19,7 +19,7 @@ import java.security.SecureRandom; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static com.minersstudios.msessentials.utility.MessageUtils.RolePlayActionType.ME; import static com.minersstudios.msessentials.utility.MessageUtils.sendRPEventMessage; import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal; @@ -39,8 +39,8 @@ public final class TryCommand extends AbstractCommandExecutor { .build(); private static final TranslatableComponent[] VARIANTS = new TranslatableComponent[] { - COMMAND_TRY_VARIANT_SUCCESS.color(NamedTextColor.GREEN), - COMMAND_TRY_VARIANT_FAIL.color(NamedTextColor.RED) + COMMAND_TRY_VARIANT_SUCCESS.asTranslatable().color(NamedTextColor.GREEN), + COMMAND_TRY_VARIANT_FAIL.asTranslatable().color(NamedTextColor.RED) }; private final SecureRandom random = new SecureRandom(); @@ -62,8 +62,9 @@ public boolean onCommand( if (playerInfo.isMuted()) { MSLogger.warning( player, - COMMAND_MUTE_ALREADY_RECEIVER + COMMAND_MUTE_ALREADY_RECEIVER.asTranslatable() ); + return true; } @@ -74,6 +75,7 @@ public boolean onCommand( .append(VARIANTS[this.random.nextInt(2)]), ME ); + return true; } diff --git a/src/main/java/com/minersstudios/msessentials/discord/BotHandler.java b/src/main/java/com/minersstudios/msessentials/discord/BotHandler.java index a53c4944..a96e367f 100644 --- a/src/main/java/com/minersstudios/msessentials/discord/BotHandler.java +++ b/src/main/java/com/minersstudios/msessentials/discord/BotHandler.java @@ -1,7 +1,6 @@ package com.minersstudios.msessentials.discord; import com.minersstudios.mscore.inventory.CustomInventory; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.msessentials.MSEssentials; import com.minersstudios.msessentials.command.impl.discord.EditSkinCommand; @@ -21,8 +20,8 @@ import java.util.Locale; import java.util.regex.Pattern; -import static com.minersstudios.mscore.language.LanguageFile.renderTranslation; -import static com.minersstudios.mscore.language.LanguageRegistry.Strings.*; +import static com.minersstudios.mscore.locale.Translations.*; +import static com.minersstudios.mscore.utility.ChatUtils.serializePlainComponent; import static net.kyori.adventure.text.Component.text; public final class BotHandler { @@ -44,9 +43,9 @@ public final class BotHandler { private static final String LIST_INDEX_REGEX = "\\d{1,2}"; private static final Pattern LIST_INDEX_PATTERN = Pattern.compile(LIST_INDEX_REGEX); - private static final String MENU_TITLE = "§f" + MENU_DISCORD_TITLE; - private static final String VARIANT_YES = DISCORD_SKIN_VARIANT_YES.toLowerCase(Locale.ROOT); - private static final String VARIANT_NO = DISCORD_SKIN_VARIANT_NO.toLowerCase(Locale.ROOT); + private static final String MENU_TITLE = "§f" + MENU_DISCORD_TITLE.asString(); + private static final String VARIANT_YES = DISCORD_SKIN_VARIANT_YES.asString().toLowerCase(Locale.ROOT); + private static final String VARIANT_NO = DISCORD_SKIN_VARIANT_NO.asString().toLowerCase(Locale.ROOT); public BotHandler( final @NotNull MSEssentials plugin, @@ -95,12 +94,14 @@ public void handleMessage(final @NotNull Message message) { short code = 0; if (!this.plugin.getCache().getDiscordManager().isVerified(this.user)) { - this.reply(DISCORD_NOT_A_USER); + this.reply(DISCORD_NOT_A_USER.asString()); + return; } if (this.isFlooding()) { - this.reply(DISCORD_MESSAGE_ATTEMPTS_LIMIT_REACHED); + this.reply(DISCORD_MESSAGE_ATTEMPTS_LIMIT_REACHED.asString()); + return; } @@ -108,6 +109,7 @@ public void handleMessage(final @NotNull Message message) { if (this.waitingReplyTask.run()) { this.waitingReplyTask = null; } + return; } @@ -115,17 +117,23 @@ public void handleMessage(final @NotNull Message message) { try { code = Short.parseShort(this.messageString); } catch (final NumberFormatException ignored) { - this.reply(DISCORD_INVALID_CODE); + this.reply(DISCORD_INVALID_CODE.asString()); + return; } - if (code < 1000 || code > 9999) { - this.reply(DISCORD_INVALID_CODE); + if ( + code < 1000 + || code > 9999 + ) { + this.reply(DISCORD_INVALID_CODE.asString()); + return; } if (this.isCodeFlooding()) { - this.reply(DISCORD_CODE_ATTEMPTS_LIMIT_REACHED); + this.reply(DISCORD_CODE_ATTEMPTS_LIMIT_REACHED.asString()); + return; } } @@ -134,7 +142,8 @@ public void handleMessage(final @NotNull Message message) { code == 0 && this.playerInfo == null ) { - this.reply(DISCORD_NOT_LINKED); + this.reply(DISCORD_NOT_LINKED.asString()); + return; } @@ -144,7 +153,8 @@ public void handleMessage(final @NotNull Message message) { } if (attachmentSize > 1) { - this.reply(DISCORD_SKIN_ONLY_ONE_IMG); + this.reply(DISCORD_SKIN_ONLY_ONE_IMG.asString()); + return; } else if (attachmentSize == 1) { final Message.Attachment attachment = attachments.get(0); @@ -153,13 +163,13 @@ public void handleMessage(final @NotNull Message message) { try { this.handleSkin(link); } catch (final IllegalArgumentException ignored) { - this.reply(DISCORD_SKIN_INVALID_IMG); + this.reply(DISCORD_SKIN_INVALID_IMG.asString()); } return; } - this.reply(DISCORD_UNKNOWN_COMMAND); + this.reply(DISCORD_UNKNOWN_COMMAND.asString()); } private void reply(@NotNull String reply) { @@ -178,6 +188,7 @@ private boolean isCodeFlooding() { if (lastAttempt == 0L) { this.codeAttempt = newAttempt; + return false; } @@ -190,6 +201,7 @@ private boolean isCodeFlooding() { } this.codeAttempt = Attempt.ZERO_ATTEMPT; + return false; } @@ -214,6 +226,7 @@ private boolean isFlooding() { } this.messageAttempt = Attempt.ZERO_ATTEMPT; + return false; } @@ -222,9 +235,9 @@ private void handleCode(final short code) { final PlayerInfo fromCode = discordMap.validateCode(code); if (fromCode == null) { - this.reply(DISCORD_NO_CODE); + this.reply(DISCORD_NO_CODE.asString()); } else if (fromCode.equals(this.playerInfo)) { - this.replyEmbed(DISCORD_ALREADY_LINKED); + this.replyEmbed(DISCORD_ALREADY_LINKED.asString()); } else { this.playerInfo = fromCode; final Player onlinePlayer = fromCode.getOnlinePlayer(); @@ -232,9 +245,9 @@ private void handleCode(final short code) { discordMap.removeCode(code); fromCode.linkDiscord(this.userId); this.replyEmbed( - renderTranslation( - LanguageRegistry.Components.DISCORD_SUCCESSFULLY_LINKED - .arguments( + serializePlainComponent( + DISCORD_SUCCESSFULLY_LINKED + .asComponent( this.playerInfo.getDefaultName(), text(this.playerInfo.getNickname()) ) @@ -251,7 +264,7 @@ private void handleCode(final short code) { MSLogger.fine( onlinePlayer, - LanguageRegistry.Components.COMMAND_DISCORD_LINK_SUCCESS + COMMAND_DISCORD_LINK_SUCCESS.asTranslatable() .arguments(text(this.user.getName())) ); } @@ -262,12 +275,14 @@ private void handleSkin(final @NotNull String link) throws IllegalArgumentExcept final String skinName = this.messageString; if (skinName.isEmpty()) { - this.reply(DISCORD_SKIN_NO_NAME); + this.reply(DISCORD_SKIN_NO_NAME.asString()); + return; } if (!Skin.matchesNameRegex(skinName)) { - this.reply(DISCORD_SKIN_INVALID_NAME_REGEX); + this.reply(DISCORD_SKIN_INVALID_NAME_REGEX.asString()); + return; } @@ -276,9 +291,9 @@ private void handleSkin(final @NotNull String link) throws IllegalArgumentExcept if (playerFile.containsSkin(skinName)) { this.plugin.runTask(() -> this.handleEditTask(link, skinName)); this.replyEmbed( - renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_ALREADY_SET - .arguments( + serializePlainComponent( + DISCORD_SKIN_ALREADY_SET + .asComponent( this.playerInfo.getDefaultName(), text(this.playerInfo.getNickname()) ) @@ -292,15 +307,16 @@ private void handleSkin(final @NotNull String link) throws IllegalArgumentExcept final Skin skin = Skin.create(this.plugin, skinName, link); if (skin == null) { - this.reply(DISCORD_SKIN_SERVICE_UNAVAILABLE); + this.reply(DISCORD_SKIN_SERVICE_UNAVAILABLE.asString()); + return; } playerFile.addSkin(skin); this.replyEmbed( - renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_ADDED - .arguments( + serializePlainComponent( + DISCORD_SKIN_SUCCESSFULLY_ADDED + .asComponent( text(skinName), this.playerInfo.getDefaultName(), text(this.playerInfo.getNickname()) @@ -313,7 +329,7 @@ private void handleSkin(final @NotNull String link) throws IllegalArgumentExcept if (player != null) { MSLogger.fine( player, - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT + DISCORD_SKIN_SUCCESSFULLY_ADDED_MINECRAFT.asTranslatable() .arguments(text(skinName)) ); } @@ -321,9 +337,9 @@ private void handleSkin(final @NotNull String link) throws IllegalArgumentExcept this.plugin.runTask(this::handleShowSkinListTask); this.replyEmbed( - renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_TOO_MANY_SKINS - .arguments( + serializePlainComponent( + DISCORD_SKIN_TOO_MANY_SKINS + .asComponent( this.playerInfo.getDefaultName(), text(this.playerInfo.getNickname()) ) @@ -350,14 +366,15 @@ private void handleEditTask( if (player != null) { MSLogger.fine( player, - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_EDITED_MINECRAFT + DISCORD_SKIN_SUCCESSFULLY_EDITED_MINECRAFT.asTranslatable() .arguments(text(skinName)) ); } } else if (reply.equals(VARIANT_NO)) { - this.reply(DISCORD_SKIN_VARIANT_NO_REPLY); + this.reply(DISCORD_SKIN_VARIANT_NO_REPLY.asString()); } else { - this.reply(DISCORD_UNKNOWN_COMMAND); + this.reply(DISCORD_UNKNOWN_COMMAND.asString()); + return false; } @@ -384,15 +401,16 @@ private void handleShowSkinListTask() { .append("\""); } - this.replyEmbed(renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_LIST_OF_SKINS - .arguments(text(skinList.toString())) + this.replyEmbed(serializePlainComponent( + DISCORD_SKIN_LIST_OF_SKINS + .asComponent(text(skinList.toString())) )); this.plugin.runTask(this::handleSkinListTask); } else if (reply.equals(VARIANT_NO)) { - this.reply(DISCORD_SKIN_VARIANT_NO_REPLY); + this.reply(DISCORD_SKIN_VARIANT_NO_REPLY.asString()); } else { - this.reply(DISCORD_UNKNOWN_COMMAND); + this.reply(DISCORD_UNKNOWN_COMMAND.asString()); + return false; } @@ -403,7 +421,8 @@ private void handleShowSkinListTask() { private void handleSkinListTask() { this.waitingReplyTask = () -> { if (!LIST_INDEX_PATTERN.matcher(this.messageString).matches()) { - this.reply(DISCORD_SKIN_VARIANT_NO_REPLY); + this.reply(DISCORD_SKIN_VARIANT_NO_REPLY.asString()); + return true; } @@ -411,28 +430,32 @@ private void handleSkinListTask() { try { skinIndex = Byte.parseByte(this.messageString); } catch (final NumberFormatException ignored) { - this.reply(DISCORD_SKIN_INVALID_INDEX); + this.reply(DISCORD_SKIN_INVALID_INDEX.asString()); + return false; } final Skin skin = this.playerInfo.getPlayerFile().getSkin(skinIndex - 1); if (skin == null) { - this.reply(DISCORD_SKIN_INVALID_INDEX); + this.reply(DISCORD_SKIN_INVALID_INDEX.asString()); + return false; } this.plugin.runTask(() -> this.handleSkinTask(skin)); + return true; }; } private void handleSkinTask(final @NotNull Skin skin) { - this.replyEmbed(DISCORD_SKIN_LIST_OF_SKIN_ACTIONS); + this.replyEmbed(DISCORD_SKIN_LIST_OF_SKIN_ACTIONS.asString()); this.waitingReplyTask = () -> { if (!LIST_INDEX_PATTERN.matcher(this.messageString).matches()) { - this.reply(DISCORD_SKIN_VARIANT_NO_REPLY); + this.reply(DISCORD_SKIN_VARIANT_NO_REPLY.asString()); + return true; } @@ -440,7 +463,8 @@ private void handleSkinTask(final @NotNull Skin skin) { try { actionIndex = Byte.parseByte(this.messageString); } catch (final NumberFormatException ignored) { - this.reply(DISCORD_SKIN_INVALID_INDEX); + this.reply(DISCORD_SKIN_INVALID_INDEX.asString()); + return false; } @@ -449,7 +473,8 @@ private void handleSkinTask(final @NotNull Skin skin) { case 2 -> this.plugin.runTask(() -> this.handleEditNameTask(skin)); case 3 -> this.plugin.runTask(() -> RemoveSkinCommand.remove(playerInfo, skin, message, null)); default -> { - this.reply(DISCORD_SKIN_INVALID_INDEX); + this.reply(DISCORD_SKIN_INVALID_INDEX.asString()); + return false; } } @@ -462,14 +487,15 @@ private void handleEditImageTask(final @NotNull Skin editableSkin) { final PlayerFile playerFile = this.playerInfo.getPlayerFile(); final String skinName = editableSkin.getName(); - this.replyEmbed(DISCORD_SKIN_ACTION_EDIT_INFO); + this.replyEmbed(DISCORD_SKIN_ACTION_EDIT_INFO.asString()); this.waitingReplyTask = () -> { final var attachments = this.message.getAttachments(); switch (attachments.size()) { case 0 -> { - this.reply(DISCORD_SKIN_VARIANT_NO_REPLY); + this.reply(DISCORD_SKIN_VARIANT_NO_REPLY.asString()); + return true; } case 1 -> { @@ -489,12 +515,14 @@ private void handleEditImageTask(final @NotNull Skin editableSkin) { null ); } catch (final Throwable ignored) { - this.reply(DISCORD_SKIN_INVALID_IMG); + this.reply(DISCORD_SKIN_INVALID_IMG.asString()); + return false; } } default -> { - this.reply(DISCORD_SKIN_ONLY_ONE_IMG); + this.reply(DISCORD_SKIN_ONLY_ONE_IMG.asString()); + return false; } } @@ -505,26 +533,28 @@ private void handleEditNameTask(final @NotNull Skin editableSkin) { final PlayerFile playerFile = this.playerInfo.getPlayerFile(); final String oldName = editableSkin.getName(); - this.replyEmbed(DISCORD_SKIN_ACTION_RENAME_INFO); + this.replyEmbed(DISCORD_SKIN_ACTION_RENAME_INFO.asString()); this.waitingReplyTask = () -> { final String newName = this.messageString; if (!Skin.matchesNameRegex(newName)) { - this.reply(DISCORD_SKIN_INVALID_NAME_REGEX); + this.reply(DISCORD_SKIN_INVALID_NAME_REGEX.asString()); + return false; } if (playerFile.containsSkin(newName)) { this.replyEmbed( - renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_ALREADY_SET - .arguments( + serializePlainComponent( + DISCORD_SKIN_ALREADY_SET + .asComponent( this.playerInfo.getDefaultName(), text(this.playerInfo.getNickname()) ) ) ); + return false; } @@ -533,9 +563,9 @@ private void handleEditNameTask(final @NotNull Skin editableSkin) { Skin.create(newName, editableSkin.getValue(), editableSkin.getSignature()) ); this.replyEmbed( - renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_RENAMED - .arguments( + serializePlainComponent( + DISCORD_SKIN_SUCCESSFULLY_RENAMED + .asComponent( text(oldName), text(newName), this.playerInfo.getDefaultName(), @@ -549,7 +579,7 @@ private void handleEditNameTask(final @NotNull Skin editableSkin) { if (player != null) { MSLogger.fine( player, - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_RENAMED_MINECRAFT + DISCORD_SKIN_SUCCESSFULLY_RENAMED_MINECRAFT.asTranslatable() .arguments( text(oldName), text(newName) @@ -570,28 +600,30 @@ private boolean editSkin( final Skin skin = Skin.create(this.plugin, skinName, link); if (skin == null) { - this.reply(DISCORD_SKIN_SERVICE_UNAVAILABLE); + this.reply(DISCORD_SKIN_SERVICE_UNAVAILABLE.asString()); + return true; } playerFile.setSkin(skinIndex, skin); this.replyEmbed( - renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_EDITED - .arguments( + serializePlainComponent( + DISCORD_SKIN_SUCCESSFULLY_EDITED + .asComponent( text(skinName), this.playerInfo.getDefaultName(), text(this.playerInfo.getNickname()) ) ) ); + return false; } public static @NotNull MessageEmbed craftEmbed(final @NotNull String description) { return new MessageEmbed( null, - DISCORD_EMBED_TITLE, + DISCORD_EMBED_TITLE.asString(), description, EmbedType.RICH, null, diff --git a/src/main/java/com/minersstudios/msessentials/discord/DiscordManager.java b/src/main/java/com/minersstudios/msessentials/discord/DiscordManager.java index bdab81f3..9a991b0e 100644 --- a/src/main/java/com/minersstudios/msessentials/discord/DiscordManager.java +++ b/src/main/java/com/minersstudios/msessentials/discord/DiscordManager.java @@ -1,6 +1,5 @@ package com.minersstudios.msessentials.discord; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.msessentials.Config; import com.minersstudios.msessentials.MSEssentials; @@ -23,7 +22,6 @@ import net.dv8tion.jda.api.managers.Presence; import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.MemberCachePolicy; -import net.kyori.adventure.text.Component; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.UnknownNullability; @@ -35,6 +33,9 @@ import java.util.logging.Level; import java.util.logging.Logger; +import static com.minersstudios.mscore.locale.Translations.DISCORD_BOT_STATUS; +import static com.minersstudios.mscore.locale.Translations.DISCORD_SERVER_ENABLED; + /** * This class handles the Discord integration for the MSEssentials plugin. It * provides methods for interacting with the Discord API using JDA @@ -456,7 +457,7 @@ public void load() throws IllegalStateException { this.plugin.runTaskAsync(() -> { try { - this.plugin.setStatus(MSEssentials.LOADING_DISCORD); + this.plugin.assignStatus(MSEssentials.LOADING_DISCORD); this.jda = this.buildJda(botToken); } catch (final Throwable e) { @@ -469,7 +470,7 @@ public void load() throws IllegalStateException { if (this.jda == null) { logger.warning("Discord bot not found!"); - this.plugin.setStatus(MSEssentials.FAILED_LOAD_DISCORD); + this.plugin.assignStatus(MSEssentials.FAILED_LOAD_DISCORD); return; } @@ -478,7 +479,7 @@ public void load() throws IllegalStateException { if (this.mainGuild == null) { logger.warning("Discord server not found!"); - this.plugin.setStatus(MSEssentials.FAILED_LOAD_DISCORD); + this.plugin.assignStatus(MSEssentials.FAILED_LOAD_DISCORD); this.unload(); return; @@ -519,19 +520,16 @@ public void load() throws IllegalStateException { } presence.setActivity( - Activity.playing(ChatUtils.serializePlainComponent( - LanguageRegistry.Components.DISCORD_BOT_STATUS - .arguments( - Component.text(this.plugin.getServer().getMinecraftVersion()) - )) + Activity.playing( + DISCORD_BOT_STATUS.asString(this.plugin.getServer().getMinecraftVersion()) ) ); this.loadCommandsAndListeners(); - this.plugin.setStatus(MSEssentials.LOADED_DISCORD); + this.plugin.assignStatus(MSEssentials.LOADED_DISCORD); - this.sendMessage(ChatType.GLOBAL, LanguageRegistry.Strings.DISCORD_SERVER_ENABLED); - this.sendMessage(ChatType.LOCAL, LanguageRegistry.Strings.DISCORD_SERVER_ENABLED); + this.sendMessage(ChatType.GLOBAL, DISCORD_SERVER_ENABLED.asString()); + this.sendMessage(ChatType.LOCAL, DISCORD_SERVER_ENABLED.asString()); }); } diff --git a/src/main/java/com/minersstudios/msessentials/listener/api/discord/AbstractDiscordListener.java b/src/main/java/com/minersstudios/msessentials/listener/api/discord/AbstractDiscordListener.java index 8596c6a3..c2916a0a 100644 --- a/src/main/java/com/minersstudios/msessentials/listener/api/discord/AbstractDiscordListener.java +++ b/src/main/java/com/minersstudios/msessentials/listener/api/discord/AbstractDiscordListener.java @@ -27,7 +27,7 @@ public abstract class AbstractDiscordListener extends ListenerAdapter implements @Override public final boolean isRegistered() { return this.plugin != null - && MSEssentials.singleton().getCache().getDiscordManager().getJda() + && MSEssentials.cache().getDiscordManager().getJda() .map(jda -> jda.getRegisteredListeners().contains(this)) .orElse(false); } diff --git a/src/main/java/com/minersstudios/msessentials/listener/api/discord/DiscordListener.java b/src/main/java/com/minersstudios/msessentials/listener/api/discord/DiscordListener.java index d64e5813..4bb964e5 100644 --- a/src/main/java/com/minersstudios/msessentials/listener/api/discord/DiscordListener.java +++ b/src/main/java/com/minersstudios/msessentials/listener/api/discord/DiscordListener.java @@ -1,9 +1,6 @@ package com.minersstudios.msessentials.listener.api.discord; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * All event listeners annotated using {@link DiscordListener} will be @@ -12,6 +9,7 @@ * * @see AbstractDiscordListener */ +@Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface DiscordListener {} diff --git a/src/main/java/com/minersstudios/msessentials/listener/impl/event/chat/AsyncChatListener.java b/src/main/java/com/minersstudios/msessentials/listener/impl/event/chat/AsyncChatListener.java index af6bd83a..bb957765 100644 --- a/src/main/java/com/minersstudios/msessentials/listener/impl/event/chat/AsyncChatListener.java +++ b/src/main/java/com/minersstudios/msessentials/listener/impl/event/chat/AsyncChatListener.java @@ -1,6 +1,5 @@ package com.minersstudios.msessentials.listener.impl.event.chat; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.listener.api.event.AbstractEventListener; import com.minersstudios.mscore.listener.api.event.EventListener; import com.minersstudios.mscore.plugin.MSLogger; @@ -17,6 +16,8 @@ import java.time.Instant; +import static com.minersstudios.mscore.locale.Translations.COMMAND_MUTE_ALREADY_RECEIVER; +import static com.minersstudios.mscore.locale.Translations.WARNING_YOU_CANT_DO_THIS_NOW; import static net.kyori.adventure.text.Component.text; @EventListener @@ -36,8 +37,9 @@ public void onAsyncChat(final @NotNull AsyncChatEvent event) { ) { MSLogger.warning( player, - LanguageRegistry.Components.WARNING_YOU_CANT_DO_THIS_NOW + WARNING_YOU_CANT_DO_THIS_NOW.asTranslatable() ); + return; } @@ -51,8 +53,9 @@ public void onAsyncChat(final @NotNull AsyncChatEvent event) { if (playerInfo.isMuted()) { MSLogger.warning( player, - LanguageRegistry.Components.COMMAND_MUTE_ALREADY_RECEIVER + COMMAND_MUTE_ALREADY_RECEIVER.asTranslatable() ); + return; } diff --git a/src/main/java/com/minersstudios/msessentials/listener/impl/event/command/UnknownCommandListener.java b/src/main/java/com/minersstudios/msessentials/listener/impl/event/command/UnknownCommandListener.java index a0b5dbfa..a5d32954 100644 --- a/src/main/java/com/minersstudios/msessentials/listener/impl/event/command/UnknownCommandListener.java +++ b/src/main/java/com/minersstudios/msessentials/listener/impl/event/command/UnknownCommandListener.java @@ -1,6 +1,5 @@ package com.minersstudios.msessentials.listener.impl.event.command; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.listener.api.event.AbstractEventListener; import com.minersstudios.mscore.listener.api.event.EventListener; import com.minersstudios.mscore.plugin.MSLogger; @@ -9,6 +8,8 @@ import org.bukkit.event.command.UnknownCommandEvent; import org.jetbrains.annotations.NotNull; +import static com.minersstudios.mscore.locale.Translations.ERROR_UNKNOWN_COMMAND; + @EventListener public class UnknownCommandListener extends AbstractEventListener { @@ -17,7 +18,7 @@ public void onUnknownCommand(final @NotNull UnknownCommandEvent event) { event.message(null); MSLogger.severe( event.getSender(), - LanguageRegistry.Components.ERROR_UNKNOWN_COMMAND + ERROR_UNKNOWN_COMMAND.asTranslatable() ); } } diff --git a/src/main/java/com/minersstudios/msessentials/listener/impl/event/inventory/InventoryClickListener.java b/src/main/java/com/minersstudios/msessentials/listener/impl/event/inventory/InventoryClickListener.java index 0e9938a3..e29d940e 100644 --- a/src/main/java/com/minersstudios/msessentials/listener/impl/event/inventory/InventoryClickListener.java +++ b/src/main/java/com/minersstudios/msessentials/listener/impl/event/inventory/InventoryClickListener.java @@ -1,6 +1,6 @@ package com.minersstudios.msessentials.listener.impl.event.inventory; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.listener.api.event.AbstractEventListener; import com.minersstudios.mscore.listener.api.event.EventListener; import com.minersstudios.mscore.plugin.MSLogger; @@ -68,7 +68,7 @@ public void onInventoryClick(final @NotNull InventoryClickEvent event) { if (remove) { clickedInventory.setItem(slot, new ItemStack(Material.AIR)); MSLogger.warning( - LanguageRegistry.Components.INFO_PLAYER_ITEM_REMOVED + Translations.INFO_PLAYER_ITEM_REMOVED.asTranslatable() .arguments( player.name(), text(currentItem.toString()) diff --git a/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/AsyncPlayerPreLoginListener.java b/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/AsyncPlayerPreLoginListener.java index f0729315..a908bb2a 100644 --- a/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/AsyncPlayerPreLoginListener.java +++ b/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/AsyncPlayerPreLoginListener.java @@ -1,8 +1,8 @@ package com.minersstudios.msessentials.listener.impl.event.player; -import com.minersstudios.mscore.language.LanguageFile; import com.minersstudios.mscore.listener.api.event.AbstractEventListener; import com.minersstudios.mscore.listener.api.event.EventListener; +import com.minersstudios.mscore.locale.TranslationRegistry; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscustoms.MSCustoms; import com.minersstudios.msessentials.MSEssentials; @@ -18,7 +18,7 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.jetbrains.annotations.NotNull; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; import static org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result.*; @@ -29,25 +29,28 @@ public final class AsyncPlayerPreLoginListener extends AbstractEventListener @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -65,8 +68,8 @@ public void onAsyncPlayerPreLogin(final @NotNull AsyncPlayerPreLoginEvent event) event.disallow( KICK_BANNED, LEAVE_MESSAGE_FORMAT.arguments( - PRE_LOGIN_BANNED_TITLE, - PRE_LOGIN_BANNED_SUBTITLE.arguments( + PRE_LOGIN_BANNED_TITLE.asTranslatable(), + PRE_LOGIN_BANNED_SUBTITLE.asTranslatable().arguments( playerInfo.getBanReason(), playerInfo.getBannedTo(event.getAddress()) ) @@ -96,7 +99,7 @@ public void onAsyncPlayerPreLogin(final @NotNull AsyncPlayerPreLoginEvent event) playerFile.addIp(hostAddress); playerFile.save(); MSLogger.warning( - INFO_PLAYER_ADDED_IP + INFO_PLAYER_ADDED_IP.asTranslatable() .arguments( playerInfo.getGrayIDGoldName(), text(nickname), diff --git a/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerCommandPreprocessListener.java b/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerCommandPreprocessListener.java index 55052e7a..afe448b9 100644 --- a/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerCommandPreprocessListener.java +++ b/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerCommandPreprocessListener.java @@ -1,6 +1,6 @@ package com.minersstudios.msessentials.listener.impl.event.player; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.listener.api.event.AbstractEventListener; import com.minersstudios.mscore.listener.api.event.EventListener; import com.minersstudios.mscore.plugin.MSLogger; @@ -32,7 +32,7 @@ public void onPlayerCommandPreprocess(final @NotNull PlayerCommandPreprocessEven event.setCancelled(true); MSLogger.warning( player, - LanguageRegistry.Components.WARNING_YOU_CANT_DO_THIS_NOW + Translations.WARNING_YOU_CANT_DO_THIS_NOW.asTranslatable() ); } } diff --git a/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerEditBookListener.java b/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerEditBookListener.java index 7fe95920..2bdf40fb 100644 --- a/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerEditBookListener.java +++ b/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerEditBookListener.java @@ -1,6 +1,6 @@ package com.minersstudios.msessentials.listener.impl.event.player; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.listener.api.event.AbstractEventListener; import com.minersstudios.mscore.listener.api.event.EventListener; import com.minersstudios.msessentials.MSEssentials; @@ -31,7 +31,7 @@ public void onPlayerEditBook(final @NotNull PlayerEditBookEvent event) { event.setNewBookMeta(bookMeta .author( isAnon - ? LanguageRegistry.Components.BOOK_ANONYMOUS + ? Translations.BOOK_ANONYMOUS.asTranslatable() : playerInfo.getDefaultName() ).title( isAnon diff --git a/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerKickListener.java b/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerKickListener.java index 90bce5a4..d03429f3 100644 --- a/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerKickListener.java +++ b/src/main/java/com/minersstudios/msessentials/listener/impl/event/player/PlayerKickListener.java @@ -10,15 +10,15 @@ import org.bukkit.event.player.PlayerKickEvent; import org.jetbrains.annotations.NotNull; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; @EventListener public class PlayerKickListener extends AbstractEventListener { private static final TranslatableComponent SERVER_RESTARTING = - FORMAT_LEAVE_MESSAGE + FORMAT_LEAVE_MESSAGE.asTranslatable() .arguments( - ON_DISABLE_MESSAGE_TITLE.color(NamedTextColor.RED).decorate(TextDecoration.BOLD), - ON_DISABLE_MESSAGE_SUBTITLE.color(NamedTextColor.GRAY) + ON_DISABLE_MESSAGE_TITLE.asTranslatable().color(NamedTextColor.RED).decorate(TextDecoration.BOLD), + ON_DISABLE_MESSAGE_SUBTITLE.asTranslatable().color(NamedTextColor.GRAY) ) .color(NamedTextColor.DARK_GRAY); diff --git a/src/main/java/com/minersstudios/msessentials/menu/DiscordLinkCodeMenu.java b/src/main/java/com/minersstudios/msessentials/menu/DiscordLinkCodeMenu.java index 2c41a60e..d472f377 100644 --- a/src/main/java/com/minersstudios/msessentials/menu/DiscordLinkCodeMenu.java +++ b/src/main/java/com/minersstudios/msessentials/menu/DiscordLinkCodeMenu.java @@ -3,7 +3,6 @@ import com.minersstudios.mscore.inventory.CustomInventory; import com.minersstudios.mscore.inventory.plugin.AbstractInventoryHolder; import com.minersstudios.mscore.inventory.plugin.InventoryHolder; -import com.minersstudios.mscore.language.LanguageRegistry; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.Font; import com.minersstudios.msessentials.MSEssentials; @@ -18,22 +17,23 @@ import java.util.Arrays; import java.util.List; +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; @InventoryHolder public final class DiscordLinkCodeMenu extends AbstractInventoryHolder { - private static final Component TITLE = LanguageRegistry.Components.MENU_DISCORD_TITLE.style(ChatUtils.DEFAULT_STYLE); + private static final Component TITLE = MENU_DISCORD_TITLE.asTranslatable().style(ChatUtils.DEFAULT_STYLE); private static final List NUMBERS = Arrays.asList( - LanguageRegistry.Components.MENU_DISCORD_NUMBERS_0, - LanguageRegistry.Components.MENU_DISCORD_NUMBERS_1, - LanguageRegistry.Components.MENU_DISCORD_NUMBERS_2, - LanguageRegistry.Components.MENU_DISCORD_NUMBERS_3, - LanguageRegistry.Components.MENU_DISCORD_NUMBERS_4, - LanguageRegistry.Components.MENU_DISCORD_NUMBERS_5, - LanguageRegistry.Components.MENU_DISCORD_NUMBERS_6, - LanguageRegistry.Components.MENU_DISCORD_NUMBERS_7, - LanguageRegistry.Components.MENU_DISCORD_NUMBERS_8, - LanguageRegistry.Components.MENU_DISCORD_NUMBERS_9 + MENU_DISCORD_NUMBERS_0.asTranslatable(), + MENU_DISCORD_NUMBERS_1.asTranslatable(), + MENU_DISCORD_NUMBERS_2.asTranslatable(), + MENU_DISCORD_NUMBERS_3.asTranslatable(), + MENU_DISCORD_NUMBERS_4.asTranslatable(), + MENU_DISCORD_NUMBERS_5.asTranslatable(), + MENU_DISCORD_NUMBERS_6.asTranslatable(), + MENU_DISCORD_NUMBERS_7.asTranslatable(), + MENU_DISCORD_NUMBERS_8.asTranslatable(), + MENU_DISCORD_NUMBERS_9.asTranslatable() ); @Override diff --git a/src/main/java/com/minersstudios/msessentials/menu/PronounsMenu.java b/src/main/java/com/minersstudios/msessentials/menu/PronounsMenu.java index 926818ca..46f0eef8 100644 --- a/src/main/java/com/minersstudios/msessentials/menu/PronounsMenu.java +++ b/src/main/java/com/minersstudios/msessentials/menu/PronounsMenu.java @@ -19,7 +19,7 @@ import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; @InventoryHolder public final class PronounsMenu extends AbstractInventoryHolder { @@ -31,8 +31,8 @@ public final class PronounsMenu extends AbstractInventoryHolder { final ItemMeta heMeta = heItem.getItemMeta(); final var loreHe = new ObjectArrayList(); - heMeta.displayName(MENU_PRONOUNS_BUTTON_HE_TITLE.style(ChatUtils.DEFAULT_STYLE)); - loreHe.add(MENU_PRONOUNS_BUTTON_HE_LORE.style(ChatUtils.COLORLESS_DEFAULT_STYLE).color(NamedTextColor.GRAY)); + heMeta.displayName(MENU_PRONOUNS_BUTTON_HE_TITLE.asComponent().style(ChatUtils.DEFAULT_STYLE)); + loreHe.add(MENU_PRONOUNS_BUTTON_HE_LORE.asComponent().style(ChatUtils.COLORLESS_DEFAULT_STYLE).color(NamedTextColor.GRAY)); heMeta.lore(loreHe); heItem.setItemMeta(heMeta); @@ -40,8 +40,8 @@ public final class PronounsMenu extends AbstractInventoryHolder { final ItemMeta sheMeta = sheItem.getItemMeta(); final var loreShe = new ObjectArrayList(); - sheMeta.displayName(MENU_PRONOUNS_BUTTON_SHE_TITLE.style(ChatUtils.DEFAULT_STYLE)); - loreShe.add(MENU_PRONOUNS_BUTTON_SHE_LORE.style(ChatUtils.COLORLESS_DEFAULT_STYLE).color(NamedTextColor.GRAY)); + sheMeta.displayName(MENU_PRONOUNS_BUTTON_SHE_TITLE.asComponent().style(ChatUtils.DEFAULT_STYLE)); + loreShe.add(MENU_PRONOUNS_BUTTON_SHE_LORE.asComponent().style(ChatUtils.COLORLESS_DEFAULT_STYLE).color(NamedTextColor.GRAY)); sheMeta.lore(loreShe); sheItem.setItemMeta(sheMeta); @@ -49,8 +49,8 @@ public final class PronounsMenu extends AbstractInventoryHolder { final ItemMeta theyMeta = theyItem.getItemMeta(); final var loreThey = new ObjectArrayList(); - theyMeta.displayName(MENU_PRONOUNS_BUTTON_THEY_TITLE.style(ChatUtils.DEFAULT_STYLE)); - loreThey.add(MENU_PRONOUNS_BUTTON_THEY_LORE.style(ChatUtils.COLORLESS_DEFAULT_STYLE).color(NamedTextColor.GRAY)); + theyMeta.displayName(MENU_PRONOUNS_BUTTON_THEY_TITLE.asComponent().style(ChatUtils.DEFAULT_STYLE)); + loreThey.add(MENU_PRONOUNS_BUTTON_THEY_LORE.asComponent().style(ChatUtils.COLORLESS_DEFAULT_STYLE).color(NamedTextColor.GRAY)); theyMeta.lore(loreThey); theyItem.setItemMeta(theyMeta); @@ -89,7 +89,7 @@ public final class PronounsMenu extends AbstractInventoryHolder { return CustomInventory .single( - MENU_PRONOUNS_TITLE.style(ChatUtils.DEFAULT_STYLE), + MENU_PRONOUNS_TITLE.asTranslatable().style(ChatUtils.DEFAULT_STYLE), 1 ) .buttonAt(0, heButton) diff --git a/src/main/java/com/minersstudios/msessentials/menu/ResourcePackMenu.java b/src/main/java/com/minersstudios/msessentials/menu/ResourcePackMenu.java index fd8b9ffc..24c6593d 100644 --- a/src/main/java/com/minersstudios/msessentials/menu/ResourcePackMenu.java +++ b/src/main/java/com/minersstudios/msessentials/menu/ResourcePackMenu.java @@ -19,7 +19,7 @@ import java.util.Arrays; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static com.minersstudios.mscore.utility.ChatUtils.COLORLESS_DEFAULT_STYLE; import static com.minersstudios.mscore.utility.ChatUtils.DEFAULT_STYLE; import static net.kyori.adventure.text.format.NamedTextColor.GRAY; @@ -33,58 +33,58 @@ public final class ResourcePackMenu extends AbstractInventoryHolder { - private static final Component TITLE = LanguageRegistry.Components.MENU_SKINS_TITLE.style(ChatUtils.DEFAULT_STYLE); + private static final Component TITLE = MENU_SKINS_TITLE.asTranslatable().style(ChatUtils.DEFAULT_STYLE); private static final InventoryButton EMPTY_BUTTON = new InventoryButton().item(new ItemStack(Material.AIR)); private InventoryButton applyButton; private InventoryButton applyButtonEmpty; @@ -43,7 +42,7 @@ public final class SkinsMenu extends AbstractInventoryHolder { final ItemStack applyEmpty = applyItem.clone(); final ItemMeta applyEmptyMeta = applyEmpty.getItemMeta(); - final Component applyName = LanguageRegistry.Components.MENU_SKINS_BUTTON_APPLY.style(ChatUtils.DEFAULT_STYLE); + final Component applyName = MENU_SKINS_BUTTON_APPLY.asComponent().style(ChatUtils.DEFAULT_STYLE); applyMeta.displayName(applyName); applyMeta.setCustomModelData(5004); @@ -73,7 +72,7 @@ public final class SkinsMenu extends AbstractInventoryHolder { final ItemStack deleteEmpty = deleteItem.clone(); final ItemMeta deleteEmptyMeta = deleteEmpty.getItemMeta(); - final Component deleteName = LanguageRegistry.Components.MENU_SKINS_BUTTON_DELETE.style(ChatUtils.DEFAULT_STYLE); + final Component deleteName = MENU_SKINS_BUTTON_DELETE.asComponent().style(ChatUtils.DEFAULT_STYLE); deleteMeta.displayName(deleteName); deleteMeta.setCustomModelData(5005); @@ -100,13 +99,13 @@ public final class SkinsMenu extends AbstractInventoryHolder { playerFile.removeSkin(selectedSkin); MSLogger.fine( player, - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT + DISCORD_SKIN_SUCCESSFULLY_REMOVED_MINECRAFT.asTranslatable() .arguments(skinName) ); playerInfo.sendPrivateDiscordMessage(BotHandler.craftEmbed( - LanguageFile.renderTranslation( - LanguageRegistry.Components.DISCORD_SKIN_SUCCESSFULLY_REMOVED - .arguments( + ChatUtils.serializePlainComponent( + DISCORD_SKIN_SUCCESSFULLY_REMOVED + .asComponent( skinName, playerInfo.getDefaultName(), text(playerInfo.getNickname()) @@ -116,7 +115,7 @@ public final class SkinsMenu extends AbstractInventoryHolder { } catch (final Throwable ignored) { MSLogger.severe( player, - LanguageRegistry.Components.ERROR_SOMETHING_WENT_WRONG + ERROR_SOMETHING_WENT_WRONG.asTranslatable() ); } diff --git a/src/main/java/com/minersstudios/msessentials/player/PlayerFile.java b/src/main/java/com/minersstudios/msessentials/player/PlayerFile.java index 8ce1145a..3080254e 100644 --- a/src/main/java/com/minersstudios/msessentials/player/PlayerFile.java +++ b/src/main/java/com/minersstudios/msessentials/player/PlayerFile.java @@ -18,7 +18,7 @@ import java.util.*; import java.util.logging.Level; -import static com.minersstudios.mscore.language.LanguageRegistry.Strings.*; +import static com.minersstudios.mscore.locale.Translations.*; /** * Player file with player data, settings, etc. @@ -57,10 +57,10 @@ private PlayerFile( this.config = config; this.playerName = PlayerName.create( - config.getString("name.nickname", PLAYER_NAME_NICKNAME), - config.getString("name.first-name", PLAYER_NAME_FIRST_NAME), - config.getString("name.last-name", PLAYER_NAME_LAST_NAME), - config.getString("name.patronymic", PLAYER_NAME_PATRONYMIC) + config.getString("name.nickname", PLAYER_NAME_NICKNAME.asString()), + config.getString("name.first-name", PLAYER_NAME_FIRST_NAME.asString()), + config.getString("name.last-name", PLAYER_NAME_LAST_NAME.asString()), + config.getString("name.patronymic", PLAYER_NAME_PATRONYMIC.asString()) ); this.pronouns = Pronouns.valueOf(config.getString("pronouns", "HE")); this.ipList = config.getStringList("ip-list"); diff --git a/src/main/java/com/minersstudios/msessentials/player/PlayerInfo.java b/src/main/java/com/minersstudios/msessentials/player/PlayerInfo.java index 98469d0c..f59bf0db 100644 --- a/src/main/java/com/minersstudios/msessentials/player/PlayerInfo.java +++ b/src/main/java/com/minersstudios/msessentials/player/PlayerInfo.java @@ -2,10 +2,10 @@ import com.destroystokyo.paper.profile.PlayerProfile; import com.minersstudios.mscore.inventory.CustomInventory; -import com.minersstudios.mscore.language.LanguageFile; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.BlockUtils; +import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.mscore.utility.DateUtils; import com.minersstudios.mscore.utility.PlayerUtils; import com.minersstudios.msessentials.Cache; @@ -52,7 +52,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeoutException; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; import static com.minersstudios.msessentials.utility.MessageUtils.RolePlayActionType.ME; import static com.minersstudios.msessentials.utility.MessageUtils.RolePlayActionType.TODO; import static com.minersstudios.msessentials.utility.MessageUtils.*; @@ -578,8 +578,8 @@ public boolean setWhiteListed(final boolean value) { userWhiteList.remove(gameProfile); this.kick( - COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_TITLE, - COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_SUBTITLE, + COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_TITLE.asTranslatable(), + COMMAND_WHITE_LIST_REMOVE_RECEIVER_MESSAGE_SUBTITLE.asTranslatable(), PlayerKickEvent.Cause.WHITELIST ); } @@ -870,19 +870,20 @@ public void setMuted( if (this.isMuted()) { MSLogger.warning( sender, - COMMAND_MUTE_ALREADY_SENDER + COMMAND_MUTE_ALREADY_SENDER.asTranslatable() .arguments( this.getGrayIDGoldName(), text(this.nickname) ) ); + return; } muteMap.put(this.offlinePlayer, date, reason, sender.getName()); MSLogger.fine( sender, - COMMAND_MUTE_MESSAGE_SENDER + COMMAND_MUTE_MESSAGE_SENDER.asTranslatable() .arguments( this.getGrayIDGreenName(), text(this.nickname), @@ -894,7 +895,7 @@ public void setMuted( if (player != null) { MSLogger.warning( player, - COMMAND_MUTE_MESSAGE_RECEIVER + COMMAND_MUTE_MESSAGE_RECEIVER.asTranslatable() .arguments( text(reason), text(DateUtils.getSenderDate(date, sender)) @@ -905,7 +906,7 @@ public void setMuted( if (!this.isMuted()) { MSLogger.warning( sender, - COMMAND_UNMUTE_NOT_MUTED + COMMAND_UNMUTE_NOT_MUTED.asTranslatable() .arguments( this.getGrayIDGoldName(), text(this.nickname) @@ -917,7 +918,7 @@ public void setMuted( muteMap.remove(this.offlinePlayer); MSLogger.fine( sender, - COMMAND_UNMUTE_SENDER_MESSAGE + COMMAND_UNMUTE_SENDER_MESSAGE.asTranslatable() .arguments( this.getGrayIDGreenName(), text(this.nickname) @@ -927,22 +928,22 @@ public void setMuted( if (player != null) { MSLogger.warning( player, - COMMAND_UNMUTE_RECEIVER_MESSAGE + COMMAND_UNMUTE_RECEIVER_MESSAGE.asTranslatable() ); } } if (this.isLinked()) { this.sendPrivateDiscordMessage(BotHandler.craftEmbed( - LanguageFile.renderTranslation( + ChatUtils.serializePlainComponent( value - ? DISCORD_MUTED.arguments( + ? DISCORD_MUTED.asComponent( this.defaultName, text(this.nickname), text(reason), text(DateUtils.getSenderDate(date, player)) ) - : DISCORD_UNMUTED.arguments( + : DISCORD_UNMUTED.asComponent( this.defaultName, text(this.nickname) ) @@ -973,7 +974,7 @@ public void unmute(final @NotNull CommandSender commandSender) { /** * @return The ban reason of the player from {@link BanList.Type#PROFILE} - * or {@link LanguageRegistry.Components#COMMAND_BAN_DEFAULT_REASON} + * or {@link Translations#COMMAND_BAN_DEFAULT_REASON} * if the reason is null * @throws IllegalStateException If the player is not banned, check * {@link #isBanned()} first @@ -988,7 +989,7 @@ public void unmute(final @NotNull CommandSender commandSender) { final String reason = banEntry.getReason(); return reason == null - ? COMMAND_BAN_DEFAULT_REASON + ? COMMAND_BAN_DEFAULT_REASON.asTranslatable() : text(reason); } @@ -1102,7 +1103,7 @@ public void setBannedBy(final @NotNull String source) throws IllegalStateExcepti final Date expiration = banEntry.getExpiration(); return expiration == null - ? COMMAND_BAN_TIME_FOREVER + ? COMMAND_BAN_TIME_FOREVER.asTranslatable() : text(DateUtils.getSenderDate(expiration.toInstant(), sender)); } @@ -1124,7 +1125,7 @@ public void setBannedBy(final @NotNull String source) throws IllegalStateExcepti final Date expiration = banEntry.getExpiration(); return expiration == null - ? COMMAND_BAN_TIME_FOREVER + ? COMMAND_BAN_TIME_FOREVER.asTranslatable() : text(DateUtils.getDate(expiration.toInstant(), address)); } @@ -1191,7 +1192,7 @@ public void setBanned( if (this.isBanned()) { MSLogger.warning( sender, - COMMAND_BAN_ALREADY_SENDER + COMMAND_BAN_ALREADY_SENDER.asTranslatable() .arguments( this.getGrayIDGoldName(), text(this.nickname) @@ -1202,8 +1203,8 @@ public void setBanned( banList.addBan(this.profile, reason, Date.from(date), commandSender.getName()); this.kick( - COMMAND_BAN_MESSAGE_RECEIVER_TITLE, - COMMAND_BAN_MESSAGE_RECEIVER_SUBTITLE + COMMAND_BAN_MESSAGE_RECEIVER_TITLE.asTranslatable(), + COMMAND_BAN_MESSAGE_RECEIVER_SUBTITLE.asTranslatable() .arguments( text(reason), text(DateUtils.getSenderDate(date, player)) @@ -1212,7 +1213,7 @@ public void setBanned( ); MSLogger.fine( sender, - COMMAND_BAN_MESSAGE_SENDER + COMMAND_BAN_MESSAGE_SENDER.asTranslatable() .arguments( this.getGrayIDGreenName(), text(this.nickname), @@ -1224,7 +1225,7 @@ public void setBanned( if (!this.isBanned()) { MSLogger.warning( sender, - COMMAND_UNBAN_NOT_BANNED + COMMAND_UNBAN_NOT_BANNED.asTranslatable() .arguments( this.getGrayIDGoldName(), text(this.nickname) @@ -1236,7 +1237,7 @@ public void setBanned( banList.pardon(this.profile); MSLogger.fine( sender, - COMMAND_UNBAN_MESSAGE_SENDER + COMMAND_UNBAN_MESSAGE_SENDER.asTranslatable() .arguments( this.getGrayIDGreenName(), text(this.nickname) @@ -1246,15 +1247,15 @@ public void setBanned( if (this.isLinked()) { this.sendPrivateDiscordMessage(BotHandler.craftEmbed( - LanguageFile.renderTranslation( + ChatUtils.serializePlainComponent( value - ? DISCORD_BANNED.arguments( + ? DISCORD_BANNED.asComponent( this.defaultName, text(this.nickname), text(reason), text(DateUtils.getSenderDate(date, player)) ) - : DISCORD_UNBANNED.arguments( + : DISCORD_UNBANNED.asComponent( this.defaultName, text(this.nickname) ) @@ -1511,7 +1512,7 @@ public void handleQuit(final @Nullable Player player) { switch (status) { case SUCCESSFULLY_LOADED -> { componentLogger.info( - RESOURCE_PACK_SUCCESSFULLY_LOADED + RESOURCE_PACK_SUCCESSFULLY_LOADED.asTranslatable() .arguments(text(this.nickname, NamedTextColor.GREEN)) ); return true; @@ -1521,27 +1522,28 @@ public void handleQuit(final @Nullable Player player) { playerSettings.save(); componentLogger.warn( - RESOURCE_PACK_FAILED_DOWNLOAD_CONSOLE + RESOURCE_PACK_FAILED_DOWNLOAD_CONSOLE.asTranslatable() .arguments(text(this.nickname, NamedTextColor.GOLD)) ); this.kick( - RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_TITLE, - RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_SUBTITLE, + RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_TITLE.asTranslatable(), + RESOURCE_PACK_FAILED_DOWNLOAD_RECEIVER_SUBTITLE.asTranslatable(), PlayerKickEvent.Cause.RESOURCE_PACK_REJECTION ); } case DECLINED -> { componentLogger.warn( - RESOURCE_PACK_DECLINED_CONSOLE + RESOURCE_PACK_DECLINED_CONSOLE.asTranslatable() .arguments(text(this.nickname, NamedTextColor.GOLD)) ); this.kick( - RESOURCE_PACK_DECLINED_RECEIVER_TITLE, - RESOURCE_PACK_DECLINED_RECEIVER_SUBTITLE, + RESOURCE_PACK_DECLINED_RECEIVER_TITLE.asTranslatable(), + RESOURCE_PACK_DECLINED_RECEIVER_SUBTITLE.asTranslatable(), PlayerKickEvent.Cause.RESOURCE_PACK_REJECTION ); } } + return false; }) .exceptionally( @@ -1551,8 +1553,8 @@ public void handleQuit(final @Nullable Player player) { throwable ); this.kick( - SOMETHING_WENT_WRONG_TITLE, - SOMETHING_WENT_WRONG_SUBTITLE + SOMETHING_WENT_WRONG_TITLE.asTranslatable(), + SOMETHING_WENT_WRONG_SUBTITLE.asTranslatable() ); return false; @@ -1647,7 +1649,7 @@ public void createPlayerFile() { this.playerFile.save(); this.plugin.getComponentLogger().info( - INFO_PLAYER_FILE_CREATED + INFO_PLAYER_FILE_CREATED.asTranslatable() .arguments( text(this.nickname), text(this.offlinePlayer.getUniqueId().toString()) @@ -1739,9 +1741,9 @@ public void kick( ) { this.kick( player, - COMMAND_KICK_MESSAGE_RECEIVER_TITLE, - COMMAND_KICK_MESSAGE_RECEIVER_SUBTITLE - .arguments(COMMAND_KICK_DEFAULT_REASON), + COMMAND_KICK_MESSAGE_RECEIVER_TITLE.asTranslatable(), + COMMAND_KICK_MESSAGE_RECEIVER_SUBTITLE.asTranslatable() + .arguments(COMMAND_KICK_DEFAULT_REASON.asTranslatable()), cause ); } @@ -1786,7 +1788,7 @@ public void kick( } player.kick( - FORMAT_LEAVE_MESSAGE + FORMAT_LEAVE_MESSAGE.asTranslatable() .arguments( title.color(NamedTextColor.RED).decorate(TextDecoration.BOLD), reason.color(NamedTextColor.GRAY) diff --git a/src/main/java/com/minersstudios/msessentials/player/Pronouns.java b/src/main/java/com/minersstudios/msessentials/player/Pronouns.java index a49d21ef..e232f74d 100644 --- a/src/main/java/com/minersstudios/msessentials/player/Pronouns.java +++ b/src/main/java/com/minersstudios/msessentials/player/Pronouns.java @@ -1,11 +1,11 @@ package com.minersstudios.msessentials.player; -import com.minersstudios.mscore.language.LanguageFile; -import net.kyori.adventure.text.Component; +import com.minersstudios.mscore.locale.LanguageFile; +import net.kyori.adventure.text.TranslatableComponent; import org.jetbrains.annotations.NotNull; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.*; +import static com.minersstudios.mscore.locale.Translations.*; /** * Pronouns enum with custom messages. All messages stored in the @@ -15,69 +15,69 @@ */ public enum Pronouns { HE( - PLAYER_PRONOUNS_HE_JOIN, - PLAYER_PRONOUNS_HE_QUIT, - PLAYER_PRONOUNS_HE_SPIT, - PLAYER_PRONOUNS_HE_FART, - PLAYER_PRONOUNS_HE_PRONOUNS, - PLAYER_PRONOUNS_HE_TRAVELER, - PLAYER_PRONOUNS_HE_SIT, - PLAYER_PRONOUNS_HE_GET_UP, - PLAYER_PRONOUNS_HE_DEATH, - PLAYER_PRONOUNS_HE_KILL, - PLAYER_PRONOUNS_HE_SAID + PLAYER_PRONOUNS_HE_JOIN.asTranslatable(), + PLAYER_PRONOUNS_HE_QUIT.asTranslatable(), + PLAYER_PRONOUNS_HE_SPIT.asTranslatable(), + PLAYER_PRONOUNS_HE_FART.asTranslatable(), + PLAYER_PRONOUNS_HE_PRONOUNS.asTranslatable(), + PLAYER_PRONOUNS_HE_TRAVELER.asTranslatable(), + PLAYER_PRONOUNS_HE_SIT.asTranslatable(), + PLAYER_PRONOUNS_HE_GET_UP.asTranslatable(), + PLAYER_PRONOUNS_HE_DEATH.asTranslatable(), + PLAYER_PRONOUNS_HE_KILL.asTranslatable(), + PLAYER_PRONOUNS_HE_SAID.asTranslatable() ), SHE( - PLAYER_PRONOUNS_SHE_JOIN, - PLAYER_PRONOUNS_SHE_QUIT, - PLAYER_PRONOUNS_SHE_SPIT, - PLAYER_PRONOUNS_SHE_FART, - PLAYER_PRONOUNS_SHE_PRONOUNS, - PLAYER_PRONOUNS_SHE_TRAVELER, - PLAYER_PRONOUNS_SHE_SIT, - PLAYER_PRONOUNS_SHE_GET_UP, - PLAYER_PRONOUNS_SHE_DEATH, - PLAYER_PRONOUNS_SHE_KILL, - PLAYER_PRONOUNS_SHE_SAID + PLAYER_PRONOUNS_SHE_JOIN.asTranslatable(), + PLAYER_PRONOUNS_SHE_QUIT.asTranslatable(), + PLAYER_PRONOUNS_SHE_SPIT.asTranslatable(), + PLAYER_PRONOUNS_SHE_FART.asTranslatable(), + PLAYER_PRONOUNS_SHE_PRONOUNS.asTranslatable(), + PLAYER_PRONOUNS_SHE_TRAVELER.asTranslatable(), + PLAYER_PRONOUNS_SHE_SIT.asTranslatable(), + PLAYER_PRONOUNS_SHE_GET_UP.asTranslatable(), + PLAYER_PRONOUNS_SHE_DEATH.asTranslatable(), + PLAYER_PRONOUNS_SHE_KILL.asTranslatable(), + PLAYER_PRONOUNS_SHE_SAID.asTranslatable() ), THEY( - PLAYER_PRONOUNS_THEY_JOIN, - PLAYER_PRONOUNS_THEY_QUIT, - PLAYER_PRONOUNS_THEY_SPIT, - PLAYER_PRONOUNS_THEY_FART, - PLAYER_PRONOUNS_THEY_PRONOUNS, - PLAYER_PRONOUNS_THEY_TRAVELER, - PLAYER_PRONOUNS_THEY_SIT, - PLAYER_PRONOUNS_THEY_GET_UP, - PLAYER_PRONOUNS_THEY_DEATH, - PLAYER_PRONOUNS_THEY_KILL, - PLAYER_PRONOUNS_THEY_SAID + PLAYER_PRONOUNS_THEY_JOIN.asTranslatable(), + PLAYER_PRONOUNS_THEY_QUIT.asTranslatable(), + PLAYER_PRONOUNS_THEY_SPIT.asTranslatable(), + PLAYER_PRONOUNS_THEY_FART.asTranslatable(), + PLAYER_PRONOUNS_THEY_PRONOUNS.asTranslatable(), + PLAYER_PRONOUNS_THEY_TRAVELER.asTranslatable(), + PLAYER_PRONOUNS_THEY_SIT.asTranslatable(), + PLAYER_PRONOUNS_THEY_GET_UP.asTranslatable(), + PLAYER_PRONOUNS_THEY_DEATH.asTranslatable(), + PLAYER_PRONOUNS_THEY_KILL.asTranslatable(), + PLAYER_PRONOUNS_THEY_SAID.asTranslatable() ); - private final Component joinMessage; - private final Component quitMessage; - private final Component spitMessage; - private final Component fartMessage; - private final Component pronouns; - private final Component traveler; - private final Component sitMessage; - private final Component unSitMessage; - private final Component deathMessage; - private final Component killMessage; - private final Component saidMessage; + private final TranslatableComponent joinMessage; + private final TranslatableComponent quitMessage; + private final TranslatableComponent spitMessage; + private final TranslatableComponent fartMessage; + private final TranslatableComponent pronouns; + private final TranslatableComponent traveler; + private final TranslatableComponent sitMessage; + private final TranslatableComponent unSitMessage; + private final TranslatableComponent deathMessage; + private final TranslatableComponent killMessage; + private final TranslatableComponent saidMessage; Pronouns( - final @NotNull Component joinMessage, - final @NotNull Component quitMessage, - final @NotNull Component spitMessage, - final @NotNull Component fartMessage, - final @NotNull Component pronouns, - final @NotNull Component traveler, - final @NotNull Component sitMessage, - final @NotNull Component unSitMessage, - final @NotNull Component deathMessage, - final @NotNull Component killMessage, - final @NotNull Component saidMessage + final @NotNull TranslatableComponent joinMessage, + final @NotNull TranslatableComponent quitMessage, + final @NotNull TranslatableComponent spitMessage, + final @NotNull TranslatableComponent fartMessage, + final @NotNull TranslatableComponent pronouns, + final @NotNull TranslatableComponent traveler, + final @NotNull TranslatableComponent sitMessage, + final @NotNull TranslatableComponent unSitMessage, + final @NotNull TranslatableComponent deathMessage, + final @NotNull TranslatableComponent killMessage, + final @NotNull TranslatableComponent saidMessage ) { this.joinMessage = joinMessage; this.quitMessage = quitMessage; @@ -92,47 +92,47 @@ public enum Pronouns { this.saidMessage = saidMessage; } - public @NotNull Component getJoinMessage() { + public @NotNull TranslatableComponent getJoinMessage() { return this.joinMessage; } - public @NotNull Component getQuitMessage() { + public @NotNull TranslatableComponent getQuitMessage() { return this.quitMessage; } - public @NotNull Component getSpitMessage() { + public @NotNull TranslatableComponent getSpitMessage() { return this.spitMessage; } - public @NotNull Component getFartMessage() { + public @NotNull TranslatableComponent getFartMessage() { return this.fartMessage; } - public @NotNull Component getPronouns() { + public @NotNull TranslatableComponent getPronouns() { return this.pronouns; } - public @NotNull Component getTraveler() { + public @NotNull TranslatableComponent getTraveler() { return this.traveler; } - public @NotNull Component getSitMessage() { + public @NotNull TranslatableComponent getSitMessage() { return this.sitMessage; } - public @NotNull Component getUnSitMessage() { + public @NotNull TranslatableComponent getUnSitMessage() { return this.unSitMessage; } - public @NotNull Component getDeathMessage() { + public @NotNull TranslatableComponent getDeathMessage() { return this.deathMessage; } - public @NotNull Component getKillMessage() { + public @NotNull TranslatableComponent getKillMessage() { return this.killMessage; } - public @NotNull Component getSaidMessage() { + public @NotNull TranslatableComponent getSaidMessage() { return this.saidMessage; } } diff --git a/src/main/java/com/minersstudios/msessentials/player/RegistrationProcess.java b/src/main/java/com/minersstudios/msessentials/player/RegistrationProcess.java index c82af9b8..17b8c9ca 100644 --- a/src/main/java/com/minersstudios/msessentials/player/RegistrationProcess.java +++ b/src/main/java/com/minersstudios/msessentials/player/RegistrationProcess.java @@ -1,8 +1,7 @@ package com.minersstudios.msessentials.player; import com.minersstudios.mscore.inventory.SignMenu; -import com.minersstudios.mscore.language.LanguageFile; -import com.minersstudios.mscore.language.LanguageRegistry; +import com.minersstudios.mscore.locale.LanguageFile; import com.minersstudios.msessentials.MSEssentials; import com.minersstudios.msessentials.menu.PronounsMenu; import com.minersstudios.msessentials.utility.MSPlayerUtils; @@ -15,6 +14,9 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; +import java.util.Locale; + +import static com.minersstudios.mscore.locale.Translations.*; import static net.kyori.adventure.text.Component.text; /** @@ -43,23 +45,25 @@ public void registerPlayer(final @NotNull PlayerInfo playerInfo) { this.player.playSound(this.playerLocation, Sound.MUSIC_DISC_FAR, SoundCategory.MUSIC, 0.15f, 1.25f); playerInfo.createPlayerFile(); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_0, 100L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_1, 150L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_2, 225L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_3, 300L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_4, 350L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_5, 400L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_6, 450L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_0.asTranslatable(), 100L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_1.asTranslatable(), 150L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_2.asTranslatable(), 225L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_3.asTranslatable(), 300L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_4.asTranslatable(), 350L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_5.asTranslatable(), 400L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_6.asTranslatable(), 450L); this.plugin.runTaskLater(this::setFirstname, 550L); } private void setFirstname() { + final Locale locale = this.player.locale(); + new SignMenu( - LanguageRegistry.Components.REGISTRATION_SIGN_FIRST_NAME_0, - LanguageRegistry.Components.REGISTRATION_SIGN_FIRST_NAME_1, - LanguageRegistry.Components.REGISTRATION_SIGN_FIRST_NAME_2, - LanguageRegistry.Components.REGISTRATION_SIGN_FIRST_NAME_3, + REGISTRATION_SIGN_FIRST_NAME_0.asComponent(locale), + REGISTRATION_SIGN_FIRST_NAME_1.asComponent(locale), + REGISTRATION_SIGN_FIRST_NAME_2.asComponent(locale), + REGISTRATION_SIGN_FIRST_NAME_3.asComponent(locale), (player, strings) -> { final String firstname = strings[0].trim(); @@ -70,10 +74,10 @@ private void setFirstname() { this.playerInfo.getPlayerFile().getPlayerName().setFirstName(firstname); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_7, 25L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_8, 100L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_9, 225L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_10, 300L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_7.asTranslatable(), 25L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_8.asTranslatable(), 100L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_9.asTranslatable(), 225L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_10.asTranslatable(), 300L); this.plugin.runTaskLater(this::setLastname, 375L); @@ -83,11 +87,13 @@ private void setFirstname() { } private void setLastname() { + final Locale locale = this.player.locale(); + new SignMenu( - LanguageRegistry.Components.REGISTRATION_SIGN_LAST_NAME_0, - LanguageRegistry.Components.REGISTRATION_SIGN_LAST_NAME_1, - LanguageRegistry.Components.REGISTRATION_SIGN_LAST_NAME_2, - LanguageRegistry.Components.REGISTRATION_SIGN_LAST_NAME_3, + REGISTRATION_SIGN_LAST_NAME_0.asComponent(locale), + REGISTRATION_SIGN_LAST_NAME_1.asComponent(locale), + REGISTRATION_SIGN_LAST_NAME_2.asComponent(locale), + REGISTRATION_SIGN_LAST_NAME_3.asComponent(locale), (player, strings) -> { final String lastname = strings[0].trim(); @@ -105,11 +111,13 @@ private void setLastname() { } private void setPatronymic() { + final Locale locale = this.player.locale(); + new SignMenu( - LanguageRegistry.Components.REGISTRATION_SIGN_PATRONYMIC_0, - LanguageRegistry.Components.REGISTRATION_SIGN_PATRONYMIC_1, - LanguageRegistry.Components.REGISTRATION_SIGN_PATRONYMIC_2, - LanguageRegistry.Components.REGISTRATION_SIGN_PATRONYMIC_3, + REGISTRATION_SIGN_PATRONYMIC_0.asComponent(locale), + REGISTRATION_SIGN_PATRONYMIC_1.asComponent(locale), + REGISTRATION_SIGN_PATRONYMIC_2.asComponent(locale), + REGISTRATION_SIGN_PATRONYMIC_3.asComponent(locale), (player, strings) -> { final String patronymic = strings[0].trim(); @@ -127,7 +135,7 @@ private void setPatronymic() { this.playerInfo.initNames(); this.sendDialogueMessage( - LanguageRegistry.Components.REGISTRATION_MESSAGE_11.arguments( + REGISTRATION_MESSAGE_11.asTranslatable().arguments( text(this.playerInfo.getID(true, false)), text(name.getFirstName()), text(name.getLastName()), @@ -135,8 +143,8 @@ private void setPatronymic() { ), 25L ); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_12, 100L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_13, 150L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_12.asTranslatable(), 100L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_13.asTranslatable(), 150L); this.plugin.runTaskLater( () -> this.plugin.openCustomInventory(PronounsMenu.class, this.player), @@ -157,11 +165,11 @@ public void setPronouns( this.playerInfo = playerInfo; final Pronouns pronouns = this.playerInfo.getPlayerFile().getPronouns(); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_14, 25L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_15, 75L); - this.sendDialogueMessage(LanguageRegistry.Components.REGISTRATION_MESSAGE_16, 125L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_14.asTranslatable(), 25L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_15.asTranslatable(), 75L); + this.sendDialogueMessage(REGISTRATION_MESSAGE_16.asTranslatable(), 125L); this.sendDialogueMessage( - LanguageRegistry.Components.REGISTRATION_MESSAGE_17 + REGISTRATION_MESSAGE_17.asTranslatable() .arguments( pronouns.getPronouns(), pronouns.getTraveler() @@ -181,8 +189,8 @@ private void setOther() { private void sendWarningMessage() { this.player.sendMessage( - LanguageRegistry.Components.REGISTRATION_ONLY_CYRILLIC - .color(NamedTextColor.GOLD) + REGISTRATION_ONLY_CYRILLIC.asTranslatable() + .color(NamedTextColor.GOLD) ); } @@ -192,9 +200,9 @@ private void sendDialogueMessage( ) { this.plugin.runTaskLater(() -> { this.player.sendMessage( - LanguageRegistry.Components.CHAT_LOCAL_FORMAT + CHAT_LOCAL_FORMAT.asTranslatable() .arguments( - LanguageRegistry.Components.REGISTRATION_ANONYMOUS_NAME, + REGISTRATION_ANONYMOUS_NAME.asTranslatable(), message.color(MessageUtils.Colors.CHAT_COLOR_SECONDARY) ) .color(MessageUtils.Colors.CHAT_COLOR_PRIMARY) diff --git a/src/main/java/com/minersstudios/msessentials/resourcepack/ResourcePackLoader.java b/src/main/java/com/minersstudios/msessentials/resourcepack/ResourcePackLoader.java index 538a7bfe..f1305140 100644 --- a/src/main/java/com/minersstudios/msessentials/resourcepack/ResourcePackLoader.java +++ b/src/main/java/com/minersstudios/msessentials/resourcepack/ResourcePackLoader.java @@ -3,9 +3,9 @@ import com.minersstudios.mscore.plugin.MSLogger; import com.minersstudios.mscore.utility.ChatUtils; import com.minersstudios.msessentials.resourcepack.data.ResourcePackData; -import com.minersstudios.msessentials.resourcepack.resource.GitHubResourceManager; -import com.minersstudios.msessentials.resourcepack.resource.ResourceManager; -import com.minersstudios.msessentials.resourcepack.resource.Tag; +import com.minersstudios.msessentials.resourcepack.resource.GitHubPackResourceManager; +import com.minersstudios.msessentials.resourcepack.resource.PackResourceManager; +import com.minersstudios.mscore.resource.github.Tag; import com.minersstudios.msessentials.resourcepack.throwable.FatalPackLoadException; import com.minersstudios.msessentials.resourcepack.throwable.PackLoadException; import it.unimi.dsi.fastutil.objects.ObjectArrayList; @@ -57,24 +57,24 @@ public final class ResourcePackLoader { // // - public static final String ENABLED_KEY = "enabled"; - public static final String AUTO_UPDATE_KEY = "auto-update"; - public static final String NAME_KEY = "name"; - public static final String DESCRIPTION_KEY = "description"; - public static final String FILE_NAME_KEY = "file-name"; - - public static final String DATA_SECTION_KEY = "data"; - public static final String UUID_KEY = "uuid"; - public static final String URL_KEY = "url"; - public static final String HASH_KEY = "hash"; - public static final String PROMPT_KEY = "prompt"; - public static final String REQUIRED_KEY = "required"; - - public static final String GITHUB_SECTION_KEY = "github"; - public static final String TOKEN_KEY = "token"; - public static final String USER_KEY = "user"; - public static final String REPO_KEY = "repo"; - public static final String TAG_KEY = "tag"; + public static final String KEY_ENABLED = "enabled"; + public static final String KEY_AUTO_UPDATE = "auto-update"; + public static final String KEY_NAME = "name"; + public static final String KEY_DESCRIPTION = "description"; + public static final String KEY_FILE_NAME = "file-name"; + + public static final String KEY_DATA_SECTION = "data"; + public static final String KEY_UUID = "uuid"; + public static final String KEY_URL = "url"; + public static final String KEY_HASH = "hash"; + public static final String KEY_PROMPT = "prompt"; + public static final String KEY_REQUIRED = "required"; + + public static final String KEY_GITHUB_SECTION = "github"; + public static final String KEY_TOKEN = "token"; + public static final String KEY_USER = "user"; + public static final String KEY_REPO = "repo"; + public static final String KEY_TAG = "tag"; // ResourcePackLoader( @@ -97,7 +97,7 @@ public final class ResourcePackLoader { .thenCompose(ignored -> this.isEnabled ? this.setupBuilder() - .thenCompose(ResourcePackData.Builder::buildAsync) + .thenCompose(ResourcePackData.Builder::buildAsync) : completedFuture(ResourcePackData.empty()) ) .thenApply( @@ -150,17 +150,17 @@ public final class ResourcePackLoader { } private @NotNull CompletableFuture setupBase() throws FatalPackLoadException { - final String nameString = this.section.getString(NAME_KEY); + final String nameString = this.section.getString(KEY_NAME); if (ChatUtils.isBlank(nameString)) { throw new FatalPackLoadException("Name cannot be null or blank"); } - final var descriptionList = this.section.getStringList(DESCRIPTION_KEY); + final var descriptionList = this.section.getStringList(KEY_DESCRIPTION); final int descriptionSize = descriptionList.size(); - this.isEnabled = this.section.getBoolean(ENABLED_KEY); - this.isAutoUpdateEnabled = this.section.getBoolean(AUTO_UPDATE_KEY); + this.isEnabled = this.section.getBoolean(KEY_ENABLED); + this.isAutoUpdateEnabled = this.section.getBoolean(KEY_AUTO_UPDATE); this.name = MiniMessage.miniMessage().deserialize(nameString, TagResolver.standard()); this.description = new Component[descriptionSize]; @@ -176,42 +176,42 @@ public final class ResourcePackLoader { return completedFuture(null); } - this.fileName = this.section.getString(FILE_NAME_KEY); + this.fileName = this.section.getString(KEY_FILE_NAME); if (ChatUtils.isBlank(this.fileName)) { return this.failed("File name cannot be null or blank"); } - this.dataSection = this.section.getConfigurationSection(DATA_SECTION_KEY); + this.dataSection = this.section.getConfigurationSection(KEY_DATA_SECTION); if (this.dataSection == null) { return this.failed("Data section cannot be null"); } - this.uuid = this.dataSection.getString(UUID_KEY); + this.uuid = this.dataSection.getString(KEY_UUID); if (ChatUtils.isBlank(this.uuid)) { this.onBuiltConsumers.add( - builder -> this.dataSection.set(UUID_KEY, builder.uuid().toString()) + builder -> this.dataSection.set(KEY_UUID, builder.uuid().toString()) ); } - this.url = this.dataSection.getString(URL_KEY); - this.hash = this.dataSection.getString(HASH_KEY); - final String promptString = dataSection.getString(PROMPT_KEY); + this.url = this.dataSection.getString(KEY_URL); + this.hash = this.dataSection.getString(KEY_HASH); + final String promptString = dataSection.getString(KEY_PROMPT); this.prompt = ChatUtils.isBlank(promptString) ? null : MiniMessage.miniMessage().deserialize(promptString, TagResolver.standard()); - this.isRequired = this.dataSection.getBoolean(REQUIRED_KEY); + this.isRequired = this.dataSection.getBoolean(KEY_REQUIRED); - this.githubSection = this.section.getConfigurationSection(GITHUB_SECTION_KEY); + this.githubSection = this.section.getConfigurationSection(KEY_GITHUB_SECTION); if (this.githubSection != null) { - this.user = this.githubSection.getString(USER_KEY); - this.repo = this.githubSection.getString(REPO_KEY); - this.tag = this.githubSection.getString(TAG_KEY); + this.user = this.githubSection.getString(KEY_USER); + this.repo = this.githubSection.getString(KEY_REPO); + this.tag = this.githubSection.getString(KEY_TAG); } return completedFuture(null); @@ -223,48 +223,48 @@ public final class ResourcePackLoader { if (ChatUtils.isNotBlank(this.url)) { if (this.isAutoUpdateEnabled) { this.onBuiltConsumers.add( - builder0 -> this.dataSection.set(HASH_KEY, builder0.hash()) + builder0 -> this.dataSection.set(KEY_HASH, builder0.hash()) ); builder - .resourceManager(ResourceManager.url(this.url)); + .resourceManager(PackResourceManager.url(this.url)); } } else { if (this.githubSection == null) { return this.failed("GitHub section cannot be null if URL is not provided"); } - this.user = this.githubSection.getString(USER_KEY); + this.user = this.githubSection.getString(KEY_USER); if (ChatUtils.isBlank(this.user)) { return this.failed("User cannot be null or blank"); } - this.repo = this.githubSection.getString(REPO_KEY); + this.repo = this.githubSection.getString(KEY_REPO); if (ChatUtils.isBlank(this.repo)) { return this.failed("Repo cannot be null or blank"); } - this.tag = this.githubSection.getString(TAG_KEY); + this.tag = this.githubSection.getString(KEY_TAG); this.onBuiltConsumers.add( builder0 -> { - final GitHubResourceManager manager = (GitHubResourceManager) builder0.resourceManager(); + final GitHubPackResourceManager manager = (GitHubPackResourceManager) builder0.resourceManager(); final Tag tag = manager.getLatestTagNow(); if (tag != null) { - this.githubSection.set(TAG_KEY, tag.getName()); + this.githubSection.set(KEY_TAG, tag.getName()); } - this.dataSection.set(HASH_KEY, builder0.hash()); + this.dataSection.set(KEY_HASH, builder0.hash()); } ); builder .resourceManager( - ResourceManager.github( + PackResourceManager.github( new File(this.configFile.getParent(), this.fileName), this.user, this.repo, this.tag, - this.githubSection.getString(TOKEN_KEY) + this.githubSection.getString(KEY_TOKEN) ) ); } @@ -292,7 +292,7 @@ public final class ResourcePackLoader { this.yaml.save(this.configFile); } catch (final Throwable e) { MSLogger.warning( - "Failed to save resource pack configuration file: " + this.configFile, + "Failed to save the configuration file: " + this.configFile, e ); } diff --git a/src/main/java/com/minersstudios/msessentials/resourcepack/data/ResourcePackData.java b/src/main/java/com/minersstudios/msessentials/resourcepack/data/ResourcePackData.java index e7f66d9b..bd326d25 100644 --- a/src/main/java/com/minersstudios/msessentials/resourcepack/data/ResourcePackData.java +++ b/src/main/java/com/minersstudios/msessentials/resourcepack/data/ResourcePackData.java @@ -1,6 +1,6 @@ package com.minersstudios.msessentials.resourcepack.data; -import com.minersstudios.msessentials.resourcepack.resource.ResourceManager; +import com.minersstudios.msessentials.resourcepack.resource.PackResourceManager; import net.kyori.adventure.resource.ResourcePackInfo; import net.kyori.adventure.resource.ResourcePackInfoLike; import net.kyori.adventure.text.Component; @@ -39,71 +39,6 @@ */ public interface ResourcePackData extends ResourcePackInfoLike { - /** - * Returns resource pack data with a random UUID, an empty URL, an empty - * hash, a null prompt, and a required status of false. The hash code of - * this data will always be 0. - * - * @return An empty resource pack data constant - */ - static @NotNull ResourcePackData empty() { - return EmptyResourcePackData.SINGLETON; - } - - /** - * Returns a new builder based on the specified resource pack info - * - * @param info The resource pack info - * @return A new builder based on the specified resource pack info - */ - @Contract("_ -> new") - static @NotNull Builder builder(final @NotNull ResourcePackInfo info) { - return new ResourcePackDataImpl.BuilderImpl(info); - } - - /** - * Creates a new builder for a {@link ResourcePackData} - * - * @return A new builder - */ - @Contract(" -> new") - static @NotNull Builder builder() { - return new ResourcePackDataImpl.BuilderImpl(); - } - - /** - * Creates new resource pack data based on the specified info with a null - * prompt and a required status of false. - * - * @param info The resource pack info - * @return New resource pack data based on the specified info with a null - * prompt and a required status of false - * @see #of(ResourcePackInfo, Component, boolean) - */ - @Contract("_ -> new") - static @NotNull ResourcePackData of(final @NotNull ResourcePackInfo info) { - return of(info, null, false); - } - - /** - * Creates new resource pack data based on the specified info, prompt, and - * required status. - * - * @param info The resource pack info - * @param prompt The prompt displayed to the user when accepting a pack - * @param required Whether the resource pack is required - * @return New resource pack data based on the specified info, prompt, and - * required status - */ - @Contract("_, _, _ -> new") - static @NotNull ResourcePackData of( - final @NotNull ResourcePackInfo info, - final @Nullable Component prompt, - final boolean required - ) { - return new ResourcePackDataImpl(info, prompt, required); - } - /** * Gets the unique ID of the resource pack. *
@@ -204,6 +139,71 @@ public interface ResourcePackData extends ResourcePackInfoLike { @Contract(" -> new") @NotNull ResourcePackInfo asResourcePackInfo() throws UnsupportedOperationException; + /** + * Returns resource pack data with a random UUID, an empty URL, an empty + * hash, a null prompt, and a required status of false. The hash code of + * this data will always be 0. + * + * @return An empty resource pack data constant + */ + static @NotNull ResourcePackData empty() { + return EmptyResourcePackData.SINGLETON; + } + + /** + * Returns a new builder based on the specified resource pack info + * + * @param info The resource pack info + * @return A new builder based on the specified resource pack info + */ + @Contract("_ -> new") + static @NotNull Builder builder(final @NotNull ResourcePackInfo info) { + return new ResourcePackDataImpl.BuilderImpl(info); + } + + /** + * Creates a new builder for a {@link ResourcePackData} + * + * @return A new builder + */ + @Contract(" -> new") + static @NotNull Builder builder() { + return new ResourcePackDataImpl.BuilderImpl(); + } + + /** + * Creates new resource pack data based on the specified info with a null + * prompt and a required status of false. + * + * @param info The resource pack info + * @return New resource pack data based on the specified info with a null + * prompt and a required status of false + * @see #of(ResourcePackInfo, Component, boolean) + */ + @Contract("_ -> new") + static @NotNull ResourcePackData of(final @NotNull ResourcePackInfo info) { + return of(info, null, false); + } + + /** + * Creates new resource pack data based on the specified info, prompt, and + * required status. + * + * @param info The resource pack info + * @param prompt The prompt displayed to the user when accepting a pack + * @param required Whether the resource pack is required + * @return New resource pack data based on the specified info, prompt, and + * required status + */ + @Contract("_, _, _ -> new") + static @NotNull ResourcePackData of( + final @NotNull ResourcePackInfo info, + final @Nullable Component prompt, + final boolean required + ) { + return new ResourcePackDataImpl(info, prompt, required); + } + /** * A builder for a {@link ResourcePackData} */ @@ -341,7 +341,7 @@ interface Builder { * * @return The resource manager */ - @UnknownNullability ResourceManager resourceManager(); + @UnknownNullability PackResourceManager resourceManager(); /** * Sets the resource manager @@ -350,7 +350,7 @@ interface Builder { * @return This builder, for chaining */ @Contract("_ -> this") - @NotNull Builder resourceManager(final @Nullable ResourceManager resourceManager); + @NotNull Builder resourceManager(final @Nullable PackResourceManager resourceManager); /** * Returns the consumer to run when the resource pack data is built diff --git a/src/main/java/com/minersstudios/msessentials/resourcepack/data/ResourcePackDataImpl.java b/src/main/java/com/minersstudios/msessentials/resourcepack/data/ResourcePackDataImpl.java index 0d71b271..75463331 100644 --- a/src/main/java/com/minersstudios/msessentials/resourcepack/data/ResourcePackDataImpl.java +++ b/src/main/java/com/minersstudios/msessentials/resourcepack/data/ResourcePackDataImpl.java @@ -1,9 +1,9 @@ package com.minersstudios.msessentials.resourcepack.data; import com.minersstudios.mscore.utility.ChatUtils; -import com.minersstudios.msessentials.resourcepack.resource.GitHubResourceManager; -import com.minersstudios.msessentials.resourcepack.resource.ResourceManager; -import com.minersstudios.msessentials.resourcepack.resource.Tag; +import com.minersstudios.msessentials.resourcepack.resource.GitHubPackResourceManager; +import com.minersstudios.msessentials.resourcepack.resource.PackResourceManager; +import com.minersstudios.mscore.resource.github.Tag; import net.kyori.adventure.resource.ResourcePackInfo; import net.kyori.adventure.text.Component; import org.jetbrains.annotations.Contract; @@ -138,7 +138,7 @@ static final class BuilderImpl implements Builder { private Component prompt; private boolean required; private boolean autoUpdate; - private ResourceManager resourceManager; + private PackResourceManager resourceManager; private Consumer onBuilt; BuilderImpl() { @@ -272,13 +272,13 @@ public boolean autoUpdate() { } @Override - public @UnknownNullability ResourceManager resourceManager() { + public @UnknownNullability PackResourceManager resourceManager() { return this.resourceManager; } @Contract("_ -> this") @Override - public @NotNull ResourcePackData.Builder resourceManager(final @Nullable ResourceManager resourceManager) { + public @NotNull ResourcePackData.Builder resourceManager(final @Nullable PackResourceManager resourceManager) { this.resourceManager = resourceManager; return this; @@ -338,7 +338,7 @@ public boolean autoUpdate() { } if (this.uri() == null) { - if (this.resourceManager instanceof final GitHubResourceManager gitHubManager) { + if (this.resourceManager instanceof final GitHubPackResourceManager gitHubManager) { final Tag[] tags = gitHubManager.getTagsNow(); if ( @@ -361,36 +361,21 @@ public boolean autoUpdate() { } private @NotNull CompletableFuture getUpdatedData() { - if (this.resourceManager == null) { - return failedState("Provide a resource manager for auto-updating"); - } - - final CompletableFuture hashFuture; - - if (this.resourceManager instanceof final GitHubResourceManager gitHubManager) { - hashFuture = - gitHubManager.generateHash() - .thenApplyAsync(hash -> { - - - return hash; - }); - } else { - hashFuture = this.resourceManager.generateHash(); - } - - return hashFuture - .thenApply( - hash -> { - if (ChatUtils.isBlank(hash)) { - throw new IllegalStateException("Failed to generate hash"); - } - - this.hash.set(hash); - - return new ResourcePackDataImpl(this); - } - ); + return this.resourceManager == null + ? failedState("Provide a resource manager for auto-updating") + : this.resourceManager + .generateHash() + .thenApply( + hash -> { + if (ChatUtils.isBlank(hash)) { + throw new IllegalStateException("Failed to generate hash"); + } + + this.hash.set(hash); + + return new ResourcePackDataImpl(this); + } + ); } private static @NotNull CompletableFuture failedState(final @Nullable String message) { diff --git a/src/main/java/com/minersstudios/msessentials/resourcepack/resource/GitHubPackResourceManager.java b/src/main/java/com/minersstudios/msessentials/resourcepack/resource/GitHubPackResourceManager.java new file mode 100644 index 00000000..faf4df5c --- /dev/null +++ b/src/main/java/com/minersstudios/msessentials/resourcepack/resource/GitHubPackResourceManager.java @@ -0,0 +1,83 @@ +package com.minersstudios.msessentials.resourcepack.resource; + +import com.minersstudios.mscore.resource.github.AbstractGithubResourceManager; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.net.URI; +import java.util.concurrent.CompletableFuture; + +/** + * Represents a GitHub resource manager for a resource pack. + *
+ * It provides methods to get the URI, the hash of the resource pack file, the + * tags of the repository and the latest tag of the repository. Also, this class + * can automatically download the resource pack file from the latest release if + * the current tag is not the latest. + *
+ * You can create it using the static methods of {@link PackResourceManager} : + *
    + *
  • {@link PackResourceManager#github(File, String, String)}
  • + *
  • {@link PackResourceManager#github(File, String, String, String, String)}
  • + *
+ * + * @see PackResourceManager + */ +public final class GitHubPackResourceManager extends AbstractGithubResourceManager implements PackResourceManager { + /** + * The URL to download a release from a GitHub repository. + *
+ * Arguments: + *
    + *
  1. GitHub user
  2. + *
  3. GitHub repository
  4. + *
  5. Tag name
  6. + *
  7. File name
  8. + *
+ */ + public static final String DOWNLOAD_RELEASE_URL = "https://github.com/%s/%s/releases/download/%s/%s"; + + GitHubPackResourceManager( + final @NotNull File file, + final @NotNull String user, + final @NotNull String repo, + final @Nullable String currentTag, + final @Nullable String token + ) { + super(file, user, repo, currentTag, token); + } + + @Contract("_ -> new") + @Override + public @NotNull URI getFileUri(final @NotNull String tag) { + return URI.create( + DOWNLOAD_RELEASE_URL.formatted(this.user, this.repo, tag, this.file.getName()) + ); + } + + /** + * Downloads the resource pack file from the latest release, generates the + * {@link #SHA1} hash of the downloaded file and returns it + * + * @return The future containing the hash of the resource pack file + * @throws IllegalStateException If the repository has no tags, or if an + * error occurs while downloading/generating + * the hash of the resource pack file + */ + @Override + public @NotNull CompletableFuture generateHash() throws IllegalStateException { + return this.updateFile(false) + .thenApply(ignored -> { + try (final var in = this.openStream()) { + return PackResourceManager.generateSHA1(in); + } catch (final Throwable e) { + throw new IllegalStateException( + "Failed to generate SHA-1 hash for resource pack file: " + this.file, + e + ); + } + }); + } +} diff --git a/src/main/java/com/minersstudios/msessentials/resourcepack/resource/GitHubResourceManager.java b/src/main/java/com/minersstudios/msessentials/resourcepack/resource/GitHubResourceManager.java deleted file mode 100644 index 56f3735e..00000000 --- a/src/main/java/com/minersstudios/msessentials/resourcepack/resource/GitHubResourceManager.java +++ /dev/null @@ -1,333 +0,0 @@ -package com.minersstudios.msessentials.resourcepack.resource; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.minersstudios.mscore.utility.ChatUtils; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.File; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.atomic.AtomicReference; - -/** - * Represents a GitHub resource manager for a resource pack. - *
- * It provides methods to get the URI, the hash of the resource pack file, the - * tags of the repository and the latest tag of the repository. Also, this class - * can automatically download the resource pack file from the latest release if - * the current tag is not the latest. - *
- * You can create it using the static methods of {@link ResourceManager} : - *
    - *
  • {@link ResourceManager#github(File, String, String)}
  • - *
  • {@link ResourceManager#github(File, String, String, String, String)}
  • - *
- * - * @see ResourceManager - */ -public final class GitHubResourceManager implements ResourceManager { - private final File file; - private final String user; - private final String repo; - private final String currentTag; - private final AtomicReference tags; - private transient final String token; - - // - /** - * The URL to get the tags of a GitHub repository. - *
- * Arguments: - *
    - *
  1. GitHub user
  2. - *
  3. GitHub repository
  4. - *
- */ - public static final String TAGS_URL = "https://api.github.com/repos/%s/%s/tags"; - - /** - * The URL to download a release from a GitHub repository. - *
- * Arguments: - *
    - *
  1. GitHub user
  2. - *
  3. GitHub repository
  4. - *
  5. Tag name
  6. - *
  7. File name
  8. - *
- */ - public static final String DOWNLOAD_RELEASE_URL = "https://github.com/%s/%s/releases/download/%s/%s"; - //
- - private static final Gson GSON = - new GsonBuilder() - .setPrettyPrinting() - .create(); - - GitHubResourceManager( - final @NotNull File file, - final @NotNull String user, - final @NotNull String repo, - final @Nullable String currentTag, - final @Nullable String token - ) { - this.file = file; - this.user = user; - this.repo = repo; - this.currentTag = currentTag; - this.tags = new AtomicReference<>(null); - this.token = token; - } - - /** - * Returns the file to download the resource pack file to - * - * @return The file to download the resource pack file to - */ - public @NotNull File getFile() { - return this.file; - } - - /** - * Returns the GitHub user - * - * @return The GitHub user - */ - public @NotNull String getUser() { - return this.user; - } - - /** - * Returns the GitHub repository - * - * @return The GitHub repository - */ - public @NotNull String getRepo() { - return this.repo; - } - - /** - * Returns the latest tag of the repository - * - * @return The latest tag of the repository - */ - public @Nullable Tag getLatestTagNow() { - final Tag[] tags = this.tags.get(); - - return tags != null - && tags.length != 0 - ? tags[0] - : null; - } - - /** - * Returns a future containing the latest tag of the repository - * - * @return A future containing the latest tag of the repository - * @throws IllegalStateException If the repository has no tags - */ - public @NotNull CompletableFuture getLatestTag() throws IllegalStateException { - return this.getTags() - .thenApplyAsync(tags -> { - if (tags.length == 0) { - throw new IllegalStateException("Provided repository has no tags"); - } - - return tags[0]; - }); - } - - /** - * Returns the tag array of the repository - * - * @return The tag array of the repository - */ - public Tag @Nullable [] getTagsNow() { - return this.tags.get(); - } - - /** - * Returns future and sets the tag array of the repository - * - * @return A future containing the tag array of the repository - */ - public @NotNull CompletableFuture getTags() { - final Tag[] tags = this.tags.get(); - - return tags != null - && tags.length != 0 - ? CompletableFuture.completedFuture(tags) - : this.updateTags(); - } - - /** - * Generates and returns a new URI from the user, repo, latest tag and file - * name fields - * - * @return The future containing the URI of the resource pack file - * @throws IllegalStateException If the latest tag has no name, or if the - * repository has no tags - */ - @Override - public @NotNull CompletableFuture getUri() throws IllegalStateException { - return this.getLatestTag() - .thenApplyAsync(tag -> { - final String tagName = tag.getName(); - - if (ChatUtils.isBlank(tagName)) { - throw new IllegalStateException("For some reason, the latest tag has no name"); - } - - return this.getReleaseUri(tagName); - }); - } - - /** - * Returns the URI of the resource pack file for the given tag - * - * @param tag The tag name - * @return The URI of the resource pack file - */ - @Contract("_ -> new") - public @NotNull URI getReleaseUri(final @NotNull String tag) { - return URI.create( - DOWNLOAD_RELEASE_URL.formatted(this.user, this.repo, tag, this.getFile().getName()) - ); - } - - /** - * Returns the repository tags URI - * - * @return The repository tags URI - */ - @Contract(" -> new") - public @NotNull URI getTagsUri() { - return URI.create( - TAGS_URL.formatted(this.user, this.repo) - ); - } - - /** - * Downloads the resource pack file from the latest release, generates the - * {@link #SHA1} hash of the downloaded file and returns it - * - * @return The future containing the hash of the resource pack file - * @throws IllegalStateException If the repository has no tags, or if an - * error occurs while downloading/generating - * the hash of the resource pack file - */ - @Override - public @NotNull CompletableFuture generateHash() throws IllegalStateException { - return this.getLatestTag() - .thenCompose( - tag -> { - final var pathFuture = - tag.getName().equals(this.currentTag) && this.file.exists() - ? CompletableFuture.completedFuture(this.file.toPath()) - : this.updateFile(); - - return pathFuture - .thenApply(path -> { - try { - return ResourceManager.generateSHA1( - Files.newInputStream(path) - ); - } catch (final Throwable e) { - throw new IllegalStateException("Failed to generate SHA-1 hash for resource pack file: " + this.file, e); - } - }); - } - ); - } - - @Override - public @NotNull String toString() { - return "GitHubResourceManager{" + - "file=" + this.getFile() + - ", user=" + this.user + - ", repo=" + this.repo + - ", tags=" + Arrays.toString(this.getTagsNow()) + - '}'; - } - - private @NotNull CompletableFuture updateFile() throws IllegalStateException { - return this.getUri() - .thenApplyAsync( - uri -> { - final Path path = this.file.toPath(); - final HttpClient client = - HttpClient.newBuilder() - .followRedirects(HttpClient.Redirect.ALWAYS) - .build(); - - try { - final int statusCode = - client.send( - HttpRequest.newBuilder(uri).build(), - HttpResponse.BodyHandlers.ofFile(path) - ).statusCode(); - - if (statusCode != HttpURLConnection.HTTP_OK) { - throw new IllegalStateException( - "Failed to update resource pack file: " + this.file + " (status code: " + statusCode + ')' - ); - } - } catch (final IOException | InterruptedException e) { - throw new IllegalStateException("Failed to update resource pack file: " + this.file, e); - } - - return path; - } - ); - } - - private @NotNull CompletableFuture updateTags() { - return CompletableFuture.supplyAsync(() -> { - final HttpRequest.Builder builder = HttpRequest.newBuilder(this.getTagsUri()).GET(); - final HttpResponse response; - - if (ChatUtils.isNotBlank(this.token)) { - builder.setHeader("Authorization", "Bearer " + this.token); - } - - try { - response = HttpClient.newHttpClient().send( - builder.build(), - HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8) - ); - } catch (final IOException | InterruptedException e) { - throw new IllegalStateException("Failed to get latest tag for " + this.user + '/' + this.repo, e); - } - - final int statusCode = response.statusCode(); - - switch (statusCode) { - case HttpURLConnection.HTTP_OK -> { - final Tag[] newTags = GSON.fromJson(response.body(), Tag[].class); - - this.tags.set(newTags); - - return newTags; - } - case HttpURLConnection.HTTP_FORBIDDEN -> throw new IllegalStateException("GitHub API rate limit exceeded"); - case HttpURLConnection.HTTP_NOT_FOUND -> throw new IllegalStateException("GitHub repository not found"); - default -> throw new IllegalStateException( - "Failed to get latest tag for " + this.user + '/' + this.repo + - "(Status code: " + statusCode + ')' - ); - } - }); - } -} diff --git a/src/main/java/com/minersstudios/msessentials/resourcepack/resource/ResourceManager.java b/src/main/java/com/minersstudios/msessentials/resourcepack/resource/PackResourceManager.java similarity index 76% rename from src/main/java/com/minersstudios/msessentials/resourcepack/resource/ResourceManager.java rename to src/main/java/com/minersstudios/msessentials/resourcepack/resource/PackResourceManager.java index 1e8a1211..ed71e7d6 100644 --- a/src/main/java/com/minersstudios/msessentials/resourcepack/resource/ResourceManager.java +++ b/src/main/java/com/minersstudios/msessentials/resourcepack/resource/PackResourceManager.java @@ -1,5 +1,6 @@ package com.minersstudios.msessentials.resourcepack.resource; +import com.minersstudios.mscore.resource.ResourceManager; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -19,8 +20,8 @@ *
* There are two types of resource managers : *
    - *
  • {@link URIResourceManager}
  • - *
  • {@link GitHubResourceManager}
  • + *
  • {@link URIPackResourceManager}
  • + *
  • {@link GitHubPackResourceManager}
  • *
* * You can create them using the static methods of this class : @@ -31,7 +32,7 @@ *
  • {@link #github(File, String, String, String, String)}
  • * */ -public interface ResourceManager { +public interface PackResourceManager extends ResourceManager { String SHA1 = "SHA-1"; /** @@ -39,11 +40,11 @@ public interface ResourceManager { *
    * Method to get URI according to resource manager type : *
      - *
    • {@link URIResourceManager} : Returns the URI passed in the - * constructor
    • - *
    • {@link GitHubResourceManager} : Generates a new URI from the user, - * repo, latest tag and file name - * fields
    • + *
    • {@link URIPackResourceManager} : Returns the URI passed in the + * constructor
    • + *
    • {@link GitHubPackResourceManager} : Generates a new URI from the + * user, repo, latest tag and + * file name fields
    • *
    * * @return The future containing the URI of the resource pack file @@ -57,12 +58,12 @@ public interface ResourceManager { *
    * Method to generate the hash according to resource manager type : *
      - *
    • {@link URIResourceManager} : Generates the hash of the file - * pointed by the URI
    • - *
    • {@link GitHubResourceManager} : Downloads the resource pack file - * from the latest release and - * generates the hash of the - * downloaded file
    • + *
    • {@link URIPackResourceManager} : Generates the hash of the + * file pointed by the URI
    • + *
    • {@link GitHubPackResourceManager} : Downloads the resource pack + * file from the latest release + * and generates the hash of the + * downloaded file
    • *
    * * @return The future containing the hash of the resource pack file @@ -72,14 +73,6 @@ public interface ResourceManager { */ @NotNull CompletableFuture generateHash() throws IllegalStateException; - /** - * Returns the string representation of this resource manager - * - * @return The string representation of this resource manager - */ - @Override - @NotNull String toString(); - /** * Creates a new resource manager for the given url * @@ -90,7 +83,7 @@ public interface ResourceManager { * @see #uri(URI) */ @Contract("_ -> new") - static @NotNull ResourceManager url(final @NotNull String url) throws IllegalArgumentException { + static @NotNull URIPackResourceManager url(final @NotNull String url) throws IllegalArgumentException { return uri(URI.create(url)); } @@ -101,8 +94,8 @@ public interface ResourceManager { * @return The resource manager for the given URI */ @Contract("_ -> new") - static @NotNull ResourceManager uri(final @NotNull URI uri) { - return new URIResourceManager(uri); + static @NotNull URIPackResourceManager uri(final @NotNull URI uri) { + return new URIPackResourceManager(uri); } /** @@ -114,7 +107,7 @@ public interface ResourceManager { * @return The resource manager for the given GitHub repository */ @Contract("_, _, _ -> new") - static @NotNull ResourceManager github( + static @NotNull GitHubPackResourceManager github( final @NotNull File file, final @NotNull String user, final @NotNull String repo @@ -133,14 +126,14 @@ public interface ResourceManager { * @return The resource manager for the given GitHub repository */ @Contract("_, _, _, _, _ -> new") - static @NotNull ResourceManager github( + static @NotNull GitHubPackResourceManager github( final @NotNull File file, final @NotNull String user, final @NotNull String repo, final @Nullable String currentTag, final @Nullable String token ) { - return new GitHubResourceManager(file, user, repo, currentTag, token); + return new GitHubPackResourceManager(file, user, repo, currentTag, token); } /** diff --git a/src/main/java/com/minersstudios/msessentials/resourcepack/resource/URIResourceManager.java b/src/main/java/com/minersstudios/msessentials/resourcepack/resource/URIPackResourceManager.java similarity index 52% rename from src/main/java/com/minersstudios/msessentials/resourcepack/resource/URIResourceManager.java rename to src/main/java/com/minersstudios/msessentials/resourcepack/resource/URIPackResourceManager.java index 1b103d18..06b58464 100644 --- a/src/main/java/com/minersstudios/msessentials/resourcepack/resource/URIResourceManager.java +++ b/src/main/java/com/minersstudios/msessentials/resourcepack/resource/URIPackResourceManager.java @@ -1,5 +1,6 @@ package com.minersstudios.msessentials.resourcepack.resource; +import com.minersstudios.mscore.resource.uri.AbstractURIResourceManager; import org.jetbrains.annotations.NotNull; import javax.annotation.concurrent.Immutable; @@ -12,30 +13,19 @@ * It provides methods to get the URI and the hash of the resource pack file * via {@link URI}. *
    - * You can create it using the static methods of {@link ResourceManager} : + * You can create it using the static methods of {@link PackResourceManager} : *
      - *
    • {@link ResourceManager#uri(URI)}
    • - *
    • {@link ResourceManager#url(String)}
    • + *
    • {@link PackResourceManager#uri(URI)}
    • + *
    • {@link PackResourceManager#url(String)}
    • *
    * - * @see ResourceManager + * @see PackResourceManager */ @Immutable -public class URIResourceManager implements ResourceManager { - private final URI uri; +public final class URIPackResourceManager extends AbstractURIResourceManager implements PackResourceManager { - URIResourceManager(final @NotNull URI uri) { - this.uri = uri; - } - - /** - * Returns the URI passed in the constructor - * - * @return The future containing the URI of the resource pack file - */ - @Override - public @NotNull CompletableFuture getUri() { - return CompletableFuture.completedFuture(this.uri); + URIPackResourceManager(final @NotNull URI uri) { + super(uri); } /** @@ -49,21 +39,11 @@ public class URIResourceManager implements ResourceManager { @Override public @NotNull CompletableFuture generateHash() throws IllegalStateException { return CompletableFuture.supplyAsync(() -> { - try { - return ResourceManager.generateSHA1( - this.uri - .toURL() - .openConnection() - .getInputStream() - ); + try (final var in = this.openStream()) { + return PackResourceManager.generateSHA1(in); } catch (final Throwable e) { throw new IllegalStateException("Failed to generate SHA-1 hash for resource pack file: " + this.uri, e); } }); } - - @Override - public @NotNull String toString() { - return "URIResourceManager{uri=" + this.uri + '}'; - } } diff --git a/src/main/java/com/minersstudios/msessentials/resourcepack/throwable/FatalPackLoadException.java b/src/main/java/com/minersstudios/msessentials/resourcepack/throwable/FatalPackLoadException.java index af8d29cc..25ad8ef6 100644 --- a/src/main/java/com/minersstudios/msessentials/resourcepack/throwable/FatalPackLoadException.java +++ b/src/main/java/com/minersstudios/msessentials/resourcepack/throwable/FatalPackLoadException.java @@ -11,14 +11,14 @@ public class FatalPackLoadException extends Exception { /** - * Constructs a FatalPackLoadException with no detail message + * Constructs a new exception with no detail message */ public FatalPackLoadException() { super(); } /** - * Constructs a FatalPackLoadException with the specified detail message + * Constructs a new exception with the specified detail message * * @param message The detail message */ diff --git a/src/main/java/com/minersstudios/msessentials/resourcepack/throwable/PackLoadException.java b/src/main/java/com/minersstudios/msessentials/resourcepack/throwable/PackLoadException.java index 4f6dd298..799033a5 100644 --- a/src/main/java/com/minersstudios/msessentials/resourcepack/throwable/PackLoadException.java +++ b/src/main/java/com/minersstudios/msessentials/resourcepack/throwable/PackLoadException.java @@ -11,14 +11,14 @@ public class PackLoadException extends RuntimeException { /** - * Constructs a PackLoadException with no detail message + * Constructs a new exception with no detail message */ public PackLoadException() { super(); } /** - * Constructs a PackLoadException with the specified detail message + * Constructs a new exception with the specified detail message * * @param message The detail message */ diff --git a/src/main/java/com/minersstudios/msessentials/utility/MessageUtils.java b/src/main/java/com/minersstudios/msessentials/utility/MessageUtils.java index ddaa3ed1..0a880898 100644 --- a/src/main/java/com/minersstudios/msessentials/utility/MessageUtils.java +++ b/src/main/java/com/minersstudios/msessentials/utility/MessageUtils.java @@ -1,9 +1,11 @@ package com.minersstudios.msessentials.utility; import com.minersstudios.mscore.MSCore; +import com.minersstudios.mscore.locale.TranslationRegistry; +import com.minersstudios.mscore.locale.Translations; import com.minersstudios.mscore.plugin.MSLogger; -import com.minersstudios.mscore.utility.Font; import com.minersstudios.mscore.utility.ChatUtils; +import com.minersstudios.mscore.utility.Font; import com.minersstudios.msessentials.Config; import com.minersstudios.msessentials.MSEssentials; import com.minersstudios.msessentials.chat.ChatType; @@ -23,7 +25,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static com.minersstudios.mscore.language.LanguageRegistry.Components.INFO_PLAYER_DEATH_INFO; import static com.minersstudios.msessentials.utility.MessageUtils.Colors.*; import static net.kyori.adventure.text.Component.*; @@ -94,7 +95,10 @@ public static void sendMessageToChat( .clickEvent(ClickEvent.suggestCommand("/pm " + playerInfo.getID() + " "))) .append(message) .color(CHAT_COLOR_SECONDARY); - final String stringLocalMessage = ChatUtils.serializePlainComponent(localMessage); + final String stringLocalMessage = + ChatUtils.serializePlainComponent( + TranslationRegistry.renderComponent(localMessage) + ); sendLocalMessage(localMessage, location, config.getLocalChatRadius()); MSEssentials.singleton().runTaskAsync( @@ -113,7 +117,10 @@ public static void sendMessageToChat( .clickEvent(ClickEvent.suggestCommand("/pm " + playerInfo.getID() + " "))) .append(message) .color(CHAT_COLOR_SECONDARY); - final String stringGlobalMessage = ChatUtils.serializePlainComponent(globalMessage); + final String stringGlobalMessage = + ChatUtils.serializePlainComponent( + TranslationRegistry.renderComponent(globalMessage) + ); sendGlobalMessage(globalMessage); MSCore.singleton().runTaskAsync(() -> { @@ -151,7 +158,10 @@ public static boolean sendPrivateMessage( .append(text(" : "))))) .color(CHAT_COLOR_PRIMARY) .append(message.color(CHAT_COLOR_SECONDARY)); - final String privateMessageString = ChatUtils.serializePlainComponent(privateMessage); + final String privateMessageString = + ChatUtils.serializePlainComponent( + TranslationRegistry.renderComponent(privateMessage) + ); commandSender.sendMessage( Font.Components.SPEECH.append(text() @@ -235,7 +245,10 @@ public static void sendRPEventMessage( config.getLocalChatRadius() ); MSCore.singleton().runTaskAsync( - () -> discordManager.sendMessage(ChatType.LOCAL, ChatUtils.serializePlainComponent(fullMessage)) + () -> discordManager.sendMessage( + ChatType.LOCAL, + ChatUtils.serializePlainComponent(TranslationRegistry.renderComponent(fullMessage)) + ) ); MSLogger.info(null, fullMessage); } @@ -278,7 +291,10 @@ public static void sendDeathMessage( .append(space())) .append(killedInfo.getPlayerFile().getPronouns().getDeathMessage()) .color(JOIN_MESSAGE_COLOR_PRIMARY); - final String stringDeathMessage = ChatUtils.serializePlainComponent(deathMessage); + final String stringDeathMessage = + ChatUtils.serializePlainComponent( + TranslationRegistry.renderComponent(deathMessage) + ); killedInfo.setLastDeathLocation(deathLocation); sendGlobalMessage(deathMessage); @@ -290,7 +306,7 @@ public static void sendDeathMessage( MSLogger.info( null, - INFO_PLAYER_DEATH_INFO + Translations.INFO_PLAYER_DEATH_INFO.asTranslatable() .arguments( killedInfo.getDefaultName(), text(killed.getName()), @@ -326,7 +342,10 @@ public static void sendJoinMessage(final @NotNull PlayerInfo playerInfo) { .append(space())) .append(playerInfo.getPlayerFile().getPronouns().getJoinMessage()) .color(JOIN_MESSAGE_COLOR_PRIMARY); - final String stringJoinMessage = ChatUtils.serializePlainComponent(joinMessage); + final String stringJoinMessage = + ChatUtils.serializePlainComponent( + TranslationRegistry.renderComponent(joinMessage) + ); sendGlobalMessage(joinMessage); MSCore.singleton().runTaskAsync(() -> { @@ -357,7 +376,10 @@ public static void sendQuitMessage( .append(space())) .append(playerInfo.getPlayerFile().getPronouns().getQuitMessage()) .color(JOIN_MESSAGE_COLOR_PRIMARY); - final String stringQuitMessage = ChatUtils.serializePlainComponent(quitMessage); + final String stringQuitMessage = + ChatUtils.serializePlainComponent( + TranslationRegistry.renderComponent(quitMessage) + ); sendGlobalMessage(quitMessage); MSCore.singleton().runTaskAsync(() -> { diff --git a/src/test/java/Main.java b/src/test/java/com/minersstudios/Main.java similarity index 83% rename from src/test/java/Main.java rename to src/test/java/com/minersstudios/Main.java index 5d029a42..729b49e7 100644 --- a/src/test/java/Main.java +++ b/src/test/java/com/minersstudios/Main.java @@ -1,3 +1,5 @@ +package com.minersstudios; + public final class Main { public static void main(final String[] args) {