From 0ae08bd18a53cccb32be2898e8f088c87fcaee1f Mon Sep 17 00:00:00 2001 From: NotRyken Date: Thu, 23 May 2024 14:48:21 +0800 Subject: [PATCH 001/107] Refactor and update to mc1.20.4 --- .editorconfig | 479 ++++++++++++++++++ .gitattributes | 15 + .github/ISSUE_TEMPLATE/bug_report.yml | 98 ++++ .github/ISSUE_TEMPLATE/config.yml | 5 + .github/ISSUE_TEMPLATE/feature_request.yml | 24 + .github/labels.yml | 115 +++++ .github/workflows/build.yml | 36 -- .github/workflows/check-build.yml | 48 ++ .github/workflows/release.yml | 57 ++- .github/workflows/sync-labels.yml | 26 + .gitignore | 32 +- LICENSE | 2 +- README.md | 24 + build.gradle | 215 ++++++-- changelog.md | 0 common/build.gradle | 35 +- .../nowplaying/LevelRendererMixinImpl.java | 19 - .../scotsguy/nowplaying/NowPlaying.java | 13 +- .../scotsguy/nowplaying/NowPlayingConfig.java | 43 -- .../nowplaying/NowPlayingListener.java | 42 -- .../scotsguy/nowplaying/config/Config.java | 125 +++++ .../gui/screen/ClothConfigScreenProvider.java | 62 +++ .../gui/screen/ConfigScreenProvider.java | 64 +++ .../{ => gui/toast}/NowPlayingToast.java | 28 +- ...inecraftMixin.java => MixinMinecraft.java} | 4 +- .../nowplaying/mixin/MixinToastInstance.java | 32 ++ .../nowplaying/mixin/RecordItemAccessor.java | 6 +- .../nowplaying/mixin/ToastInstanceMixin.java | 34 -- .../nowplaying/sound/NowPlayingListener.java | 37 ++ .../{Util.java => sound/Sound.java} | 18 +- .../nowplaying/util/Localization.java | 15 + .../scotsguy/nowplaying/util/ModLogger.java | 53 ++ .../assets/now_playing/lang/en_us.json | 81 --- .../{now_playing => nowplaying}/icon.png | Bin .../assets/nowplaying/lang/en_us.json | 81 +++ .../resources/now-playing.mixins.common.json | 15 - .../main/resources/nowplaying.accesswidener | 1 + .../src/main/resources/nowplaying.mixins.json | 20 + common/src/main/resources/pack.mcmeta | 6 + fabric/build.gradle | 126 ++--- fabric/gradle.properties | 1 - .../scotsguy/nowplaying/NowPlayingFabric.java | 10 + .../nowplaying/fabric/NowPlayingFabric.java | 17 - .../fabric/mixin/LevelRendererMixinShim.java | 17 - .../screen}/ModMenuIntegration.java | 8 +- .../nowplaying/mixin/MixinLevelRenderer.java | 27 + fabric/src/main/resources/fabric.mod.json | 95 ++-- .../resources/now-playing.mixins.fabric.json | 11 - .../resources/nowplaying.fabric.mixins.json | 17 + forge/build.gradle | 112 ---- forge/gradle.properties | 2 - .../nowplaying/forge/NowPlayingForge.java | 11 - .../forge/mixin/LevelRendererMixinShim.java | 17 - forge/src/main/resources/META-INF/mods.toml | 28 - .../resources/now-playing.mixins.forge.json | 12 - forge/src/main/resources/pack.mcmeta | 6 - gradle.properties | 96 +++- gradle/libs.versions.toml | 43 -- gradle/wrapper/gradle-wrapper.jar | Bin 59203 -> 43453 bytes gradle/wrapper/gradle-wrapper.properties | 6 +- gradlew | 53 +- gradlew.bat | 181 +++---- neoforge/build.gradle | 33 ++ .../nowplaying/NowPlayingNeoForge.java | 18 + .../nowplaying/mixin/MixinLevelRenderer.java | 27 + .../resources/META-INF/accesstransformer.cfg | 0 .../src/main/resources/META-INF/mods.toml | 50 ++ .../resources/nowplaying.neoforge.mixins.json | 17 + settings.gradle | 31 +- 69 files changed, 2148 insertions(+), 934 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/labels.yml delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/check-build.yml create mode 100644 .github/workflows/sync-labels.yml create mode 100644 README.md create mode 100644 changelog.md delete mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/LevelRendererMixinImpl.java delete mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/NowPlayingConfig.java delete mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/NowPlayingListener.java create mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/config/Config.java create mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/gui/screen/ClothConfigScreenProvider.java create mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/gui/screen/ConfigScreenProvider.java rename common/src/main/java/com/github/scotsguy/nowplaying/{ => gui/toast}/NowPlayingToast.java (74%) rename common/src/main/java/com/github/scotsguy/nowplaying/mixin/{MinecraftMixin.java => MixinMinecraft.java} (87%) create mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/mixin/MixinToastInstance.java delete mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/mixin/ToastInstanceMixin.java create mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/sound/NowPlayingListener.java rename common/src/main/java/com/github/scotsguy/nowplaying/{Util.java => sound/Sound.java} (61%) create mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/util/Localization.java create mode 100644 common/src/main/java/com/github/scotsguy/nowplaying/util/ModLogger.java delete mode 100644 common/src/main/resources/assets/now_playing/lang/en_us.json rename common/src/main/resources/assets/{now_playing => nowplaying}/icon.png (100%) create mode 100644 common/src/main/resources/assets/nowplaying/lang/en_us.json delete mode 100644 common/src/main/resources/now-playing.mixins.common.json create mode 100644 common/src/main/resources/nowplaying.accesswidener create mode 100644 common/src/main/resources/nowplaying.mixins.json create mode 100644 common/src/main/resources/pack.mcmeta delete mode 100644 fabric/gradle.properties create mode 100644 fabric/src/main/java/com/github/scotsguy/nowplaying/NowPlayingFabric.java delete mode 100644 fabric/src/main/java/com/github/scotsguy/nowplaying/fabric/NowPlayingFabric.java delete mode 100644 fabric/src/main/java/com/github/scotsguy/nowplaying/fabric/mixin/LevelRendererMixinShim.java rename fabric/src/main/java/com/github/scotsguy/nowplaying/{fabric => gui/screen}/ModMenuIntegration.java (51%) create mode 100644 fabric/src/main/java/com/github/scotsguy/nowplaying/mixin/MixinLevelRenderer.java delete mode 100644 fabric/src/main/resources/now-playing.mixins.fabric.json create mode 100644 fabric/src/main/resources/nowplaying.fabric.mixins.json delete mode 100644 forge/build.gradle delete mode 100644 forge/gradle.properties delete mode 100644 forge/src/main/java/com/github/scotsguy/nowplaying/forge/NowPlayingForge.java delete mode 100644 forge/src/main/java/com/github/scotsguy/nowplaying/forge/mixin/LevelRendererMixinShim.java delete mode 100644 forge/src/main/resources/META-INF/mods.toml delete mode 100644 forge/src/main/resources/now-playing.mixins.forge.json delete mode 100644 forge/src/main/resources/pack.mcmeta delete mode 100644 gradle/libs.versions.toml create mode 100644 neoforge/build.gradle create mode 100644 neoforge/src/main/java/com/github/scotsguy/nowplaying/NowPlayingNeoForge.java create mode 100644 neoforge/src/main/java/com/github/scotsguy/nowplaying/mixin/MixinLevelRenderer.java create mode 100644 neoforge/src/main/resources/META-INF/accesstransformer.cfg create mode 100644 neoforge/src/main/resources/META-INF/mods.toml create mode 100644 neoforge/src/main/resources/nowplaying.neoforge.mixins.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..81c4337 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,479 @@ +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 120 +tab_width = 4 +ij_continuation_indent_size = 8 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = false +ij_smart_tabs = false +ij_wrap_on_typing = false + +[*.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 = false +ij_java_align_multiline_array_initializer_expression = false +ij_java_align_multiline_assignment = false +ij_java_align_multiline_binary_operation = false +ij_java_align_multiline_chained_methods = false +ij_java_align_multiline_extends_list = false +ij_java_align_multiline_for = true +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_resources = true +ij_java_align_multiline_ternary_operation = false +ij_java_align_multiline_text_blocks = false +ij_java_align_multiline_throws_list = false +ij_java_align_subsequent_simple_methods = false +ij_java_align_throws_keyword = false +ij_java_annotation_parameter_wrap = off +ij_java_array_initializer_new_line_after_left_brace = false +ij_java_array_initializer_right_brace_on_new_line = false +ij_java_array_initializer_wrap = off +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_at_first_column = true +ij_java_call_parameters_new_line_after_left_paren = false +ij_java_call_parameters_right_paren_on_new_line = false +ij_java_call_parameters_wrap = off +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_do_not_indent_top_level_class_members = false +ij_java_do_not_wrap_after_single_annotation = false +ij_java_do_while_brace_force = never +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 = false +ij_java_doc_enable_formatting = true +ij_java_doc_enable_leading_asterisks = true +ij_java_doc_indent_on_continuation = false +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 = false +ij_java_doc_use_throws_not_exception_tag = true +ij_java_else_on_new_line = false +ij_java_enum_constants_wrap = off +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 = never +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 = false +ij_java_generate_final_parameters = false +ij_java_if_brace_force = never +ij_java_imports_layout = *, |, javax.**, java.**, |, $* +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_control_statement_in_one_line = true +ij_java_keep_first_column_comment = true +ij_java_keep_indents_on_empty_lines = false +ij_java_keep_line_breaks = true +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 = false +ij_java_keep_simple_lambdas_in_one_line = false +ij_java_keep_simple_methods_in_one_line = false +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_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 = off +ij_java_method_parameters_new_line_after_left_paren = false +ij_java_method_parameters_right_paren_on_new_line = false +ij_java_method_parameters_wrap = off +ij_java_modifier_list_wrap = false +ij_java_names_count_to_use_import_on_demand = 3 +ij_java_packages_to_use_import_on_demand = java.awt.*, javax.swing.* +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 = false +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 = false +ij_java_resource_list_right_paren_on_new_line = false +ij_java_resource_list_wrap = off +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 = true +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_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 = true +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_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 = true +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_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_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_subclass_name_suffix = Impl +ij_java_ternary_operation_signs_on_next_line = false +ij_java_ternary_operation_wrap = off +ij_java_test_name_suffix = Test +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_visibility = public +ij_java_while_brace_force = never +ij_java_while_on_new_line = false +ij_java_wrap_comments = false +ij_java_wrap_first_method_in_call_chain = false +ij_java_wrap_long_lines = false + +[*.nbtt] +max_line_length = 150 +ij_continuation_indent_size = 4 +ij_nbtt_keep_indents_on_empty_lines = false +ij_nbtt_space_after_colon = true +ij_nbtt_space_after_comma = true +ij_nbtt_space_before_colon = true +ij_nbtt_space_before_comma = false +ij_nbtt_spaces_within_brackets = false +ij_nbtt_spaces_within_parentheses = false + +[*.properties] +ij_properties_align_group_field_declarations = false + +[.editorconfig] +ij_editorconfig_align_group_field_declarations = false +ij_editorconfig_space_after_colon = false +ij_editorconfig_space_after_comma = true +ij_editorconfig_space_before_colon = false +ij_editorconfig_space_before_comma = false +ij_editorconfig_spaces_around_assignment_operators = true + +[{*.bash,*.zsh,*.sh}] +indent_size = 2 +tab_width = 2 +ij_shell_binary_ops_start_line = false +ij_shell_keep_column_alignment_padding = false +ij_shell_minify_program = false +ij_shell_redirect_followed_by_space = false +ij_shell_switch_cases_indented = false + +[{*.gant,*.groovy,*.gradle,*.gdsl,*.gy}] +ij_groovy_align_group_field_declarations = false +ij_groovy_align_multiline_array_initializer_expression = false +ij_groovy_align_multiline_assignment = false +ij_groovy_align_multiline_binary_operation = false +ij_groovy_align_multiline_chained_methods = false +ij_groovy_align_multiline_extends_list = false +ij_groovy_align_multiline_for = true +ij_groovy_align_multiline_method_parentheses = false +ij_groovy_align_multiline_parameters = true +ij_groovy_align_multiline_parameters_in_calls = false +ij_groovy_align_multiline_resources = true +ij_groovy_align_multiline_ternary_operation = false +ij_groovy_align_multiline_throws_list = false +ij_groovy_align_throws_keyword = false +ij_groovy_array_initializer_new_line_after_left_brace = false +ij_groovy_array_initializer_right_brace_on_new_line = false +ij_groovy_array_initializer_wrap = off +ij_groovy_assert_statement_wrap = off +ij_groovy_assignment_wrap = off +ij_groovy_binary_operation_wrap = off +ij_groovy_blank_lines_after_class_header = 0 +ij_groovy_blank_lines_after_imports = 1 +ij_groovy_blank_lines_after_package = 1 +ij_groovy_blank_lines_around_class = 1 +ij_groovy_blank_lines_around_field = 0 +ij_groovy_blank_lines_around_field_in_interface = 0 +ij_groovy_blank_lines_around_method = 1 +ij_groovy_blank_lines_around_method_in_interface = 1 +ij_groovy_blank_lines_before_imports = 1 +ij_groovy_blank_lines_before_method_body = 0 +ij_groovy_blank_lines_before_package = 0 +ij_groovy_block_brace_style = end_of_line +ij_groovy_block_comment_at_first_column = true +ij_groovy_call_parameters_new_line_after_left_paren = false +ij_groovy_call_parameters_right_paren_on_new_line = false +ij_groovy_call_parameters_wrap = off +ij_groovy_catch_on_new_line = false +ij_groovy_class_annotation_wrap = split_into_lines +ij_groovy_class_brace_style = end_of_line +ij_groovy_do_while_brace_force = never +ij_groovy_else_on_new_line = false +ij_groovy_enum_constants_wrap = off +ij_groovy_extends_keyword_wrap = off +ij_groovy_extends_list_wrap = off +ij_groovy_field_annotation_wrap = split_into_lines +ij_groovy_finally_on_new_line = false +ij_groovy_for_brace_force = never +ij_groovy_for_statement_new_line_after_left_paren = false +ij_groovy_for_statement_right_paren_on_new_line = false +ij_groovy_for_statement_wrap = off +ij_groovy_if_brace_force = never +ij_groovy_indent_case_from_switch = true +ij_groovy_keep_blank_lines_before_right_brace = 2 +ij_groovy_keep_blank_lines_in_code = 2 +ij_groovy_keep_blank_lines_in_declarations = 2 +ij_groovy_keep_control_statement_in_one_line = true +ij_groovy_keep_first_column_comment = true +ij_groovy_keep_indents_on_empty_lines = false +ij_groovy_keep_line_breaks = true +ij_groovy_keep_multiple_expressions_in_one_line = false +ij_groovy_keep_simple_blocks_in_one_line = false +ij_groovy_keep_simple_classes_in_one_line = true +ij_groovy_keep_simple_lambdas_in_one_line = true +ij_groovy_keep_simple_methods_in_one_line = true +ij_groovy_label_indent_absolute = false +ij_groovy_label_indent_size = 0 +ij_groovy_lambda_brace_style = end_of_line +ij_groovy_line_comment_add_space = false +ij_groovy_line_comment_at_first_column = true +ij_groovy_method_annotation_wrap = split_into_lines +ij_groovy_method_brace_style = end_of_line +ij_groovy_method_call_chain_wrap = off +ij_groovy_method_parameters_new_line_after_left_paren = false +ij_groovy_method_parameters_right_paren_on_new_line = false +ij_groovy_method_parameters_wrap = off +ij_groovy_modifier_list_wrap = false +ij_groovy_parameter_annotation_wrap = off +ij_groovy_parentheses_expression_new_line_after_left_paren = false +ij_groovy_parentheses_expression_right_paren_on_new_line = false +ij_groovy_prefer_parameters_wrap = false +ij_groovy_resource_list_new_line_after_left_paren = false +ij_groovy_resource_list_right_paren_on_new_line = false +ij_groovy_resource_list_wrap = off +ij_groovy_space_after_colon = true +ij_groovy_space_after_comma = true +ij_groovy_space_after_comma_in_type_arguments = true +ij_groovy_space_after_for_semicolon = true +ij_groovy_space_after_quest = true +ij_groovy_space_after_type_cast = true +ij_groovy_space_before_annotation_parameter_list = false +ij_groovy_space_before_array_initializer_left_brace = false +ij_groovy_space_before_catch_keyword = true +ij_groovy_space_before_catch_left_brace = true +ij_groovy_space_before_catch_parentheses = true +ij_groovy_space_before_class_left_brace = true +ij_groovy_space_before_colon = true +ij_groovy_space_before_comma = false +ij_groovy_space_before_do_left_brace = true +ij_groovy_space_before_else_keyword = true +ij_groovy_space_before_else_left_brace = true +ij_groovy_space_before_finally_keyword = true +ij_groovy_space_before_finally_left_brace = true +ij_groovy_space_before_for_left_brace = true +ij_groovy_space_before_for_parentheses = true +ij_groovy_space_before_for_semicolon = false +ij_groovy_space_before_if_left_brace = true +ij_groovy_space_before_if_parentheses = true +ij_groovy_space_before_method_call_parentheses = false +ij_groovy_space_before_method_left_brace = true +ij_groovy_space_before_method_parentheses = false +ij_groovy_space_before_quest = true +ij_groovy_space_before_switch_left_brace = true +ij_groovy_space_before_switch_parentheses = true +ij_groovy_space_before_synchronized_left_brace = true +ij_groovy_space_before_synchronized_parentheses = true +ij_groovy_space_before_try_left_brace = true +ij_groovy_space_before_try_parentheses = true +ij_groovy_space_before_while_keyword = true +ij_groovy_space_before_while_left_brace = true +ij_groovy_space_before_while_parentheses = true +ij_groovy_space_within_empty_array_initializer_braces = false +ij_groovy_space_within_empty_method_call_parentheses = false +ij_groovy_spaces_around_additive_operators = true +ij_groovy_spaces_around_assignment_operators = true +ij_groovy_spaces_around_bitwise_operators = true +ij_groovy_spaces_around_equality_operators = true +ij_groovy_spaces_around_lambda_arrow = true +ij_groovy_spaces_around_logical_operators = true +ij_groovy_spaces_around_multiplicative_operators = true +ij_groovy_spaces_around_relational_operators = true +ij_groovy_spaces_around_shift_operators = true +ij_groovy_spaces_within_annotation_parentheses = false +ij_groovy_spaces_within_array_initializer_braces = false +ij_groovy_spaces_within_braces = true +ij_groovy_spaces_within_brackets = false +ij_groovy_spaces_within_cast_parentheses = false +ij_groovy_spaces_within_catch_parentheses = false +ij_groovy_spaces_within_for_parentheses = false +ij_groovy_spaces_within_if_parentheses = false +ij_groovy_spaces_within_method_call_parentheses = false +ij_groovy_spaces_within_method_parentheses = false +ij_groovy_spaces_within_parentheses = false +ij_groovy_spaces_within_switch_parentheses = false +ij_groovy_spaces_within_synchronized_parentheses = false +ij_groovy_spaces_within_try_parentheses = false +ij_groovy_spaces_within_while_parentheses = false +ij_groovy_special_else_if_treatment = true +ij_groovy_ternary_operation_wrap = off +ij_groovy_throws_keyword_wrap = off +ij_groovy_throws_list_wrap = off +ij_groovy_use_relative_indents = false +ij_groovy_variable_annotation_wrap = off +ij_groovy_while_brace_force = never +ij_groovy_while_on_new_line = false +ij_groovy_wrap_long_lines = false + +[{*.html,*.shtm,*.sht,*.shtml,*.htm}] +ij_html_add_new_line_before_tags = body, div, p, form, h1, h2, h3 +ij_html_align_attributes = true +ij_html_align_text = false +ij_html_attribute_wrap = normal +ij_html_block_comment_at_first_column = true +ij_html_do_not_align_children_of_min_lines = 0 +ij_html_do_not_break_if_inline_tags = title, h1, h2, h3, h4, h5, h6, p +ij_html_do_not_indent_children_of_tags = html, body, thead, tbody, tfoot +ij_html_enforce_quotes = false +ij_html_inline_tags = a, abbr, acronym, b, basefont, bdo, big, br, cite, cite, code, dfn, em, font, i, img, input, kbd, label, q, s, samp, select, small, span, strike, strong, sub, sup, textarea, tt, u, var +ij_html_keep_blank_lines = 2 +ij_html_keep_indents_on_empty_lines = false +ij_html_keep_line_breaks = true +ij_html_keep_line_breaks_in_text = true +ij_html_keep_whitespaces = false +ij_html_keep_whitespaces_inside = span, pre, textarea +ij_html_line_comment_at_first_column = true +ij_html_new_line_after_last_attribute = never +ij_html_new_line_before_first_attribute = never +ij_html_quote_style = double +ij_html_remove_new_line_before_tags = br +ij_html_space_after_tag_name = false +ij_html_space_around_equality_in_attribute = false +ij_html_space_inside_empty_tag = false +ij_html_text_wrap = normal + +[{*.jhm,*.xslt,*.xul,*.tagx,*.rng,*.xsl,*.xsd,*.jspx,*.ant,*.xml,*.tld,*.fxml,*.jrxml,*.jnlp,*.wsdl,*.pom}] +ij_xml_block_comment_at_first_column = true +ij_xml_keep_indents_on_empty_lines = false +ij_xml_line_comment_at_first_column = true + +[{*.yml,*.yaml}] +indent_size = 2 +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true + +[{mcmod.info,*.json}] +indent_size = 2 +ij_json_keep_blank_lines_in_code = 0 +ij_json_keep_indents_on_empty_lines = false +ij_json_keep_line_breaks = true +ij_json_space_after_colon = true +ij_json_space_after_comma = true +ij_json_space_before_colon = true +ij_json_space_before_comma = false +ij_json_spaces_within_braces = false +ij_json_spaces_within_brackets = false +ij_json_wrap_long_lines = false \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..20fc528 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +* text eol=lf +*.bat text eol=crlf +*.patch text eol=lf +*.java text eol=lf +*.gradle text eol=crlf +*.png binary +*.gif binary +*.exe binary +*.dll binary +*.jar binary +*.lzma binary +*.zip binary +*.pyd binary +*.cfg text eol=lf +*.jks binary \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..3731735 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,98 @@ +name: Bug Report +description: "For reporting bugs and other defects" +labels: + - S/needs-triage +body: + - type: markdown + attributes: + value: >- + **This issue tracker is not intended for support requests!** Unless you are certain that + you have found a defect, and you are able to point to where the problem is, you should not + open an issue. For general support or if you're unsure, please + [ask on Discord](https://discord.gg/sSgQ9AF4mU). +

+ Additionally, please make check the following: + + - **Have you used the [search tool](https://github.com/Scotsguy/now-playing/issues) to + check whether your issue has already been reported?** If it has been, consider adding more + information to the existing issue instead. + + - **Have you determined the minimum set of instructions to reproduce the issue?** If your + problem only occurs with other mods installed, then you should narrow down exactly which + mods are causing the issue. Please do not provide your entire list of mods and expect that + we will be able to figure out the problem. + - type: input + id: mod-version + attributes: + label: Mod Version + description: >- + Specify the version(s) of the mod in which you have identified this issue. + + **Example:** `v1.2.0-Fabric-1.20.6` + validations: + required: true + - type: input + id: mod-loader + attributes: + label: Mod Loader + description: >- + Specify the mod loader(s) in which you have identified this issue. + + **Example:** `Fabric` + validations: + required: true + - type: input + id: mc-version + attributes: + label: Minecraft Version + description: >- + Specify the Minecraft version(s) in which you have identified this issue. + + **Example:** `1.20.6` + validations: + required: true + - type: textarea + id: description + attributes: + label: Bug Description + description: >- + Describe in detail the issue you are experiencing. The description should explain what + behavior you were expecting, and why you believe the issue to be a bug. If the issue you + are reporting only occurs with specific mods installed, then provide the name and version + of each mod. + + **Hint:** If you have any screenshots, videos, or other information that you feel is + necessary to explain the issue, you can attach them here. + validations: + required: true + - type: textarea + id: description-reproduction-steps + attributes: + label: Reproduction Steps + description: >- + Describe the procedure required to reproduce this bug. Make sure your instructions are as + clear and concise as possible, because other people will need to be able to follow your + guide in order to re-create the issue. + + **Hint:** A common way to fill this section out is to write a step-by-step guide. + validations: + required: true + - type: textarea + id: log-file + attributes: + label: Log File (optional) + description: >- + **Hint:** You can usually find the log files within the folder `.minecraft/logs`. Generally + you will want the `latest.log` file, since that file belongs to the last played session of + the game. + placeholder: >- + Drag-and-drop the log file here. + - type: textarea + id: crash-report-file + attributes: + label: Crash Report (optional) + description: >- + **Hint:** You can usually find crash reports (with their date and time) in the folder + `.minecraft/crash-reports`. + placeholder: >- + Drag-and-drop the crash report file here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..60cafb6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: true +contact_links: + - name: Support enquiry, Question or Discussion + url: https://discord.gg/sSgQ9AF4mU + about: For any issue that isn't specifically a bug report or feature request, please use Discord diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..32f9184 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,24 @@ +name: Feature Request +description: "For requesting new features or improvements" +labels: + - S/needs-triage + - T/enhancement +body: + - type: markdown + attributes: + value: >- + This form is for requesting new features or improvements, and should not be used for bug + reports, port requests, or other issues. + - type: markdown + attributes: + value: >- + Make sure you have used the [search tool](https://github.com/Scotsguy/now-playing/issues) + to see if a similar request already exists (either open or closed). + - type: textarea + id: description + attributes: + label: Request Description + description: >- + Use this section to describe the feature or improvement that you are looking for. The + description should explain what problem you are trying to solve, what alternatives you have + tried, and describe clearly and concisely what you would like changed. diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..b83dfba --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,115 @@ +- name: E/duplicate + color: 'BFD4F2' + description: 'Closed: Same as another' + aliases: [] + +- name: E/external + color: 'BFD4F2' + description: 'Closed: External issue' + aliases: [] + +- name: E/invalid + color: 'BFD4F2' + description: 'Closed: Not an issue' + aliases: [] + +- name: E/no-action + color: 'BFD4F2' + description: 'Closed: Not actionable or inadequate information' + aliases: [] + +- name: E/wontfix + color: 'BFD4F2' + description: 'Closed: Will not be worked on' + aliases: [] + + + +- name: P/high + color: 'B60205' + description: 'Priority: High, for immediate attention' + aliases: [] + +- name: P/low + color: '006B75' + description: 'Priority: Low, not time-sensitive' + aliases: [] + +- name: P/medium + color: '36210B' + description: 'Priority: Medium, time-sensitive but not urgent' + aliases: [] + + + +- name: S/accepted + color: '0E8A16' + description: 'Status: Request accepted' + aliases: [] + +- name: S/available + color: '006B75' + description: 'Status: Available for community contribution' + aliases: [] + +- name: S/blocked + color: '97988B' + description: 'Status: Blocked by another event' + aliases: [] + +- name: S/fixed + color: '0E8A16' + description: 'Status: Fixed' + aliases: [] + +- name: S/info-needed + color: 'FBCA04' + description: 'Status: Awaiting further information' + aliases: [] + +- name: S/in-progress + color: '0052CC' + description: 'Status: Assigned and in progress' + aliases: [] + +- name: S/needs-triage + color: '36210B' + description: 'Status: Needs triage' + aliases: [] + + + +- name: T/addition + color: '006B75' + description: 'Type: New feature' + aliases: [] + +- name: T/bug + color: 'D93F0B' + description: 'Type: Bug' + aliases: [] + +- name: T/compat + color: '36210B' + description: 'Type: Compatibility' + aliases: [] + +- name: T/enhancement + color: '0052CC' + description: 'Type: Enhancement or optimization' + aliases: [] + +- name: T/fix + color: '0E8A16' + description: 'Type: Issue fix' + aliases: [] + +- name: T/port + color: '5319E7' + description: 'Type: Upgrade or downgrade game version' + aliases: [] + +- name: T/security + color: 'B60205' + description: 'Type: Security issue' + aliases: [] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 028f069..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,36 +0,0 @@ -on: - push: - tags-ignore: - - 'v*' - branches: - - '*' - pull_request: - -name: Build Mod - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-java@v1 - with: - java-version: 17 - - name: Build - uses: gradle/gradle-build-action@v2 - with: - arguments: build --stacktrace - - name: Upload Fabric Artifacts - uses: actions/upload-artifact@v2 - with: - name: Fabric - path: | - fabric/build/libs/*.jar - release/now-playing-fabric*.jar - - name: Upload Forge Artifacts - uses: actions/upload-artifact@v2 - with: - name: Forge - path: | - forge/build/libs/*.jar - release/now-playing-forge*.jar diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml new file mode 100644 index 0000000..6697b32 --- /dev/null +++ b/.github/workflows/check-build.yml @@ -0,0 +1,48 @@ +# Builds the project on Linux and Windows as a partial defence against bad commits +name: Check Build + +on: + push: + paths: [ + '**src/**', + '**/*gradle*', + LICENSE + ] + pull_request: + paths: [ + '**src/**', + '**/*gradle*', + LICENSE + ] + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + java: [17] + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v3 + - name: Setup JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: ${{ matrix.java }} + - name: Make Gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: Build + run: ./gradlew build --stacktrace --parallel + - name: Capture build artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '17' }} + uses: actions/upload-artifact@v4 + with: + name: Artifacts + path: build/libs/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 143fbea..0fbbd37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,35 +1,38 @@ -on: - push: - tags: - - 'v*' +# Builds the project and publishes the artifacts to GitHub and Modrinth +name: Release -name: Release Mod +on: [workflow_dispatch] jobs: - build: - runs-on: ubuntu-latest + release: + strategy: + matrix: + java: [17] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v1 - - uses: actions/setup-java@v1 + - name: Checkout repository + uses: actions/checkout@v4 with: - java-version: 17 - - name: Build - uses: eskatos/gradle-command-action@v1.3.2 - with: - gradle-version: wrapper - arguments: build --stacktrace - - name: Release to Github - uses: softprops/action-gh-release@v1 - if: ${{ success() }} + fetch-depth: 0 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v3 + - name: Setup JDK ${{ matrix.java }} + uses: actions/setup-java@v4 with: - files: release/*.jar - fail_on_unmatched_files: true + distribution: zulu + java-version: ${{ matrix.java }} + - name: Make Gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: Build + run: ./gradlew build neoforge:githubRelease neoforge:modrinth fabric:githubRelease fabric:modrinth --stacktrace --parallel env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Release to CurseForge - uses: gradle/gradle-build-action@v2 - if: ${{ success() }} + GITHUB_TOKEN: ${{ secrets.GH_API_KEY }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + - name: Capture build artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '17' }} + uses: actions/upload-artifact@v4 with: - arguments: :fabric:curseforge :forge:curseforge --stacktrace - env: - CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} + name: Artifacts + path: build/libs/ diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 0000000..2090af3 --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,26 @@ +# Synchronizes the repo's labels with labels.yml +name: Sync Labels + +on: + push: + paths: ['.github/labels.yml', '.github/workflows/sync-labels.yml'] + workflow_dispatch: + +jobs: + sync: + runs-on: ubuntu-latest + env: + LABEL_SYNC_TOKEN: ${{ secrets.LABEL_SYNC_TOKEN }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/labels.yml + sparse-checkout-cone-mode: false + - name: Setup NodeJS + uses: actions/setup-node@v4 + with: + node-version: 22 + - run: npx github-label-sync -a '${{ secrets.LABEL_SYNC_TOKEN }}' -l '.github/labels.yml' ${{ github.repository }} + if: env.LABEL_SYNC_TOKEN != null diff --git a/.gitignore b/.gitignore index 5f81675..28419bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,24 @@ -.gradle -.idea -.vscode -out -build -run -.architectury-transformer -*.iml -release +# Gradle +.gradle/ + +# Artifacts bin/ +build/ +run/ +out/ +classes/ + +# IDEA +.idea/ +*.iml +*.ipr +*.iws + +# VSCode +.settings/ +.vscode/ +.classpath +.project + +# Other +.env \ No newline at end of file diff --git a/LICENSE b/LICENSE index 1d032b9..ee50ab8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 AppleTheGolden +Copyright (c) 2020-2024 AppleTheGolden Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md new file mode 100644 index 0000000..d22295f --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +
+ +## Now Playing + +[![Environment](https://img.shields.io/badge/Environment-Client-purple)]() +[![Latest Minecraft](https://img.shields.io/modrinth/game-versions/eNF4Bfla?label=Latest%20Minecraft&color=%2300AF5C)](https://modrinth.com/mod/eNF4Bfla/versions) + +[![Loader](https://img.shields.io/badge/Loader-Fabric-dbd0b4?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAcBAMAAACNPbLgAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9TpX5UHMwgIpihOtlFRRxLFYtgobQVWnUwufQLmjQkKS6OgmvBwY/FqoOLs64OroIg+AHi6uKk6CIl/i8ptIj14Lgf7+497t4BQr3MNKsrAmi6bSZjUSmTXZUCr+iHiADG0Cszy4inFtPoOL7u4ePrXZhndT735xhQcxYDfBJxhBmmTbxBPLtpG5z3iUVWlFXic+JJky5I/Mh1xeM3zgWXBZ4pmunkPLFILBXaWGljVjQ14hnikKrplC9kPFY5b3HWylXWvCd/YTCnr6S4TnMUMSwhjgQkKKiihDJshGnVSbGQpP1oB/+I60+QSyFXCYwcC6hAg+z6wf/gd7dWfnrKSwpGge4Xx/kYBwK7QKPmON/HjtM4AfzPwJXe8lfqwNwn6bWWFjoCBreBi+uWpuwBlzvA8JMhm7Ir+WkK+TzwfkbflAWGboG+Na+35j5OH4A0dbV8AxwcAhMFyl7v8O6e9t7+PdPs7wd+dXKrd9SjeQAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+cLFAcgIbOcUjoAAAAbUExURQAAAB0tQTg0KoB6bZqSfq6mlLyynMa8pdvQtJRJT6UAAAABdFJOUwBA5thmAAAAAWJLR0QB/wIt3gAAAF5JREFUGNN10FENwCAMhOFqOQuzMAtYOAtYqGw6mkEvhL59yR9Ca5YDqyOC465eKYqQm6LoCkVwnwQOBYKdeA5l51zhFtrsnPmg6m3Z2akk15dFH1lWFQVxlUFv+2sAJlA9O7NwQRQAAAAASUVORK5CYII=)](https://fabricmc.net/) +[![Loader](https://img.shields.io/badge/Loader-Quilt-9115ff?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAYAAACohjseAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV/TiqIVBwuKOASsTnZREcdSxSJYKG2FVh1MLv2CJg1Jiouj4Fpw8GOx6uDirKuDqyAIfoC4ujgpukiJ/0sKLWI8OO7Hu3uPu3eA0Kgw1QxEAVWzjFQ8JmZzq2L3K/oQQgBjGJKYqSfSixl4jq97+Ph6F+FZ3uf+HP1K3mSATySOMt2wiDeIZzctnfM+cYiVJIX4nHjSoAsSP3JddvmNc9FhgWeGjExqnjhELBY7WO5gVjJU4hnisKJqlC9kXVY4b3FWKzXWuid/YTCvraS5TnMUcSwhgSREyKihjAosRGjVSDGRov2Yh3/E8SfJJZOrDEaOBVShQnL84H/wu1uzMD3lJgVjQNeLbX+MA927QLNu29/Htt08AfzPwJXW9lcbwNwn6fW2Fj4CBraBi+u2Ju8BlzvA8JMuGZIj+WkKhQLwfkbflAMGb4HeNbe31j5OH4AMdbV8AxwcAhNFyl73eHdPZ2//nmn19wOjxHK68ogHXgAAAAlwSFlzAAAN1wAADdcBQiibeAAAAAd0SU1FB+cLFAQjO2eVRtoAAAAGYktHRAD/AP8A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Op4Mw8H7+80vZ22ImFcBxObq8Bkp3L+vnsuAAGDK49G3C7vf3/wGgBgAAAAgADJTHo2+a8TWUzKAoCnLy1GXwNtJUQmDtwHc3fSGRMPeyfnlUQ7KO9BNweV5fjTdBAwmXSAAAehOBggYdvpAkgBAf5wiiuPdukliAAA0dZwsmkg8AAAAQNEAAAAA+B8LzexYIpdh2QAAAABJRU5ErkJggg==)](https://neoforged.net/) + +[![Modrinth Downloads](https://img.shields.io/modrinth/dt/eNF4Bfla?label=Modrinth%20Downloads&logo=modrinth&logoColor=%2300AF5C)](https://modrinth.com/mod/eNF4Bfla) + +Shows a popup whenever the active music track changes. + +
+ +### License + +[MIT](https://mit-license.org/) + +### Contact + +[![GitHub Issues](https://img.shields.io/github/issues/Scotsguy/now-playing?logo=github&label=Issues)](https://github.com/Scotsguy/now-playing/issues) diff --git a/build.gradle b/build.gradle index 012875e..a7cdf73 100644 --- a/build.gradle +++ b/build.gradle @@ -1,58 +1,191 @@ -plugins { - alias(libs.plugins.architectury) - alias(libs.plugins.loom) apply false - alias(libs.plugins.vineflower) apply false - alias(libs.plugins.cursegradle) apply false -} +import com.modrinth.minotaur.dependencies.ModDependency -architectury { - minecraft = libs.versions.minecraft.get() +plugins { + id("java") + id("java-library") + id("idea") + id("maven-publish") + id("org.jetbrains.gradle.plugin.idea-ext") version("${ideaext_version}") // Required for NeoGradle + id("com.modrinth.minotaur") version("${minotaur_version}") + id("com.github.breadmoirai.github-release") version("${githubrelease_version}") + id("org.ajoberstar.grgit.service") version("${grgitservice_version}") } subprojects { - apply plugin: "dev.architectury.loom" - apply plugin: 'io.github.juuxel.loom-vineflower' - - dependencies { - minecraft libs.minecraft - if (libs.versions.useParchment.get() == "1") { - mappings loom.layered() { - officialMojangMappings() - parchment("org.parchmentmc.data:parchment-${libs.versions.minecraft.get()}:${libs.versions.parchment.get()}@zip") - } - } else { - mappings loom.officialMojangMappings() - } - } + version = mod_version + group = mod_group - loom { - silentMojangMappingsLicense() + apply(plugin: "java") + apply(plugin: "java-library") + apply(plugin: "idea") + apply(plugin: "maven-publish") + + if (project.name != "common") { + apply(plugin: "com.modrinth.minotaur") + apply(plugin: "com.github.breadmoirai.github-release") + apply(plugin: "org.ajoberstar.grgit.service") } -} -allprojects { - apply plugin: "java" - apply plugin: "architectury-plugin" - apply plugin: "maven-publish" - apply plugin: "com.matthewprenger.cursegradle" + java.toolchain.languageVersion = JavaLanguageVersion.of(Integer.valueOf(java_version)) - archivesBaseName = rootProject.archives_base_name - version = rootProject.mod_version - group = rootProject.maven_group + jar { + from(rootProject.file("LICENSE")) { + rename { "${it}_${mod_name}" } + } + manifest { + attributes([ + "Specification-Title" : mod_name, + "Specification-Vendor" : mod_owner, + "Specification-Version" : project.jar.archiveVersion, + "Implementation-Title" : project.name, + "Implementation-Version" : project.jar.archiveVersion, + "Implementation-Vendor" : mod_owner, + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "Timestamp" : System.currentTimeMillis(), + "Built-On-Java" : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", + "Built-On-Minecraft" : minecraft_version + ]) + } + } + java.withSourcesJar() + sourcesJar { + from(rootProject.file("LICENSE")) { + rename { "${it}_${mod_name}" } + } + } repositories { - maven { url "https://maven.shedaniel.me/" } - maven { url "https://maven.terraformersmc.com" } - maven { url "https://maven.parchmentmc.org" } - maven { url "https://maven.quiltmc.org/repository/release/" } + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + } + maven { + name = "Shedaniel" + url = "https://maven.shedaniel.me/" + } } tasks.withType(JavaCompile).configureEach { - options.encoding = "UTF-8" - options.release = 17 + it.options.encoding = "UTF-8" + it.options.getRelease().set(Integer.valueOf(java_version)) + } + + processResources { + def expandProps = [ + "project_group": project.group, + "mod_version": mod_version, + "mod_group": mod_group, + "mod_id": mod_id, + "mod_name": mod_name, + "mod_description": mod_description, + "mod_icon": "assets/" + mod_id + "/icon.png", + "mod_owner": mod_owner, + "mod_authors_list": asJsonList(mod_authors), + "mod_contributors_list": asJsonList(mod_contributors), + "mod_authors_string": mod_authors.replace(",", ", "), + "mod_contributors_string": mod_contributors.replace(",", ", "), + "mod_license": mod_license, + "mod_environment": mod_environment, + "java_version": java_version, + "java_versions_fabric_list": asJsonList(java_versions_fabric), + "java_versions_neoforge": java_versions_neoforge, + "minecraft_version": minecraft_version, + "minecraft_versions_fabric_list": asJsonList(minecraft_versions_fabric), + "minecraft_versions_neoforge": minecraft_versions_neoforge, + "fabric_loader_version": fabric_loader_version, + "fabric_loader_versions_list": asJsonList(fabric_loader_versions), + "fabric_api_version": fabric_api_version, + "fabric_api_versions_list": asJsonList(fabric_api_versions), + "neoforge_loader_versions": neoforge_loader_versions, + "neoforge_version": neoforge_version, + "neoforge_versions": neoforge_versions, + "clothconfig_version": clothconfig_version, + "clothconfig_versions_fabric_list": asJsonList(clothconfig_versions_fabric), + "clothconfig_versions_neoforge": clothconfig_versions_neoforge, + "modmenu_version": modmenu_version, + "modmenu_versions_list": asJsonList(modmenu_versions), + "homepage_url": homepage_url, + "sources_url": sources_url, + "issues_url": issues_url, + "contact_url": contact_url + ] + + filesMatching(["pack.mcmeta", "*.mod.json", "META-INF/*mods.toml", "*.mixins.json", "assets/"+mod_id+"/lang/*.json"]) { + expand expandProps + } + inputs.properties(expandProps) + } + + tasks.withType(GenerateModuleMetadata).configureEach { + enabled = false + } + + afterEvaluate { + if (name != "common") { + modrinth { + token = System.getenv().MODRINTH_TOKEN ? System.getenv().MODRINTH_TOKEN : "empty" + projectId = modrinth_id + versionNumber = mod_version + versionType = release_type + versionName = "v${mod_version}-${capsLoader(name)}-${minecraft_version}" + changelog = rootProject.file("changelog.md").text + uploadFile = name == "fabric" ? remapJar : jar + loaders = project.property("release_mod_loaders_${name}").split(",") as List + gameVersions = project.property("release_game_versions_${name}").split(",") as List + + def deps = [] + if (project.hasProperty("release_required_dep_ids_${name}")) { + project.property("release_required_dep_ids_${name}").split(",").each { String id -> + deps << new ModDependency(id, "required") + } + } + if (project.hasProperty("release_optional_dep_ids_${name}")) { + project.property("release_optional_dep_ids_${name}").split(",").each { String id -> + deps << new ModDependency(id, "optional") + } + } + if (project.hasProperty("release_incompatible_dep_ids_${name}")) { + project.property("release_incompatible_dep_ids_${name}").split(",").each { String id -> + deps << new ModDependency(id, "incompatible") + } + } + dependencies = deps + syncBodyFrom = rootProject.file("README.md").text + } + tasks.modrinth.onlyIf { System.getenv().MODRINTH_TOKEN } + tasks.modrinth.dependsOn(build, tasks.modrinthSyncBody) + tasks.modrinthSyncBody.onlyIf { System.getenv().MODRINTH_TOKEN } + + githubRelease { + token = System.getenv().GITHUB_TOKEN ? System.getenv().GITHUB_TOKEN : "empty" + owner = github_repo_owner + repo = github_repo + tagName = "v${mod_version}" + prerelease = release_type == "alpha" || release_type == "beta" + releaseName = "v${mod_version} for ${minecraft_version}" + body = rootProject.file("changelog.md").text + targetCommitish = grgitService.service.get().grgit.branch.current().name + overwrite = false + allowUploadToExisting = true + releaseAssets = List.of(name == "fabric" ? remapJar : jar, sourcesJar) + } + tasks.githubRelease.onlyIf { System.getenv().GITHUB_TOKEN } + tasks.githubRelease.dependsOn(build) + + } } +} + +static asJsonList(String versions) { + return versions.split(",").collect { "\"$it\"" }.join(',') +} - java { - withSourcesJar() +static String capsLoader(String loader) { + switch(loader) { + case "fabric": return "Fabric" + case "quilt": return "Quilt" + case "forge": return "Forge" + case "neoforge": return "NeoForge" + default: return loader } } diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..e69de29 diff --git a/common/build.gradle b/common/build.gradle index 970015e..b97bd8c 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,25 +1,24 @@ -dependencies { - // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies - // Do NOT use other classes from fabric loader - modImplementation libs.fabric.loader - - modImplementation libs.cloth.common +plugins { + id("org.spongepowered.gradle.vanilla") version("${vanillagradle_version}") } -architectury { - common(rootProject.enabled_platforms.split(",")) +base { + archivesName = "${mod_name}-Common-${minecraft_version}" } -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = rootProject.archives_base_name - from components.java - } - } +dependencies { + compileOnly("org.spongepowered:mixin:${mixin_version}") + + compileOnly("io.github.llamalad7:mixinextras-common:${mixinextras_version}") + annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}") + + // Using NeoForge version here to avoid having to remap + implementation("me.shedaniel.cloth:cloth-config-neoforge:${clothconfig_version}") +} - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. +minecraft { + version(minecraft_version) + if (file("src/main/resources/${mod_id}.accesswidener").exists()) { + accessWideners(file("src/main/resources/${mod_id}.accesswidener")) } } diff --git a/common/src/main/java/com/github/scotsguy/nowplaying/LevelRendererMixinImpl.java b/common/src/main/java/com/github/scotsguy/nowplaying/LevelRendererMixinImpl.java deleted file mode 100644 index 0707e91..0000000 --- a/common/src/main/java/com/github/scotsguy/nowplaying/LevelRendererMixinImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.github.scotsguy.nowplaying; - -import com.github.scotsguy.nowplaying.NowPlayingConfig; -import me.shedaniel.autoconfig.AutoConfig; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.network.chat.Component; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -public class LevelRendererMixinImpl { - public static void modifyRecordPlayingOverlay(Gui gui, Component text) { - NowPlayingConfig config = AutoConfig.getConfigHolder(NowPlayingConfig.class).getConfig(); - if (config.jukeboxStyle == NowPlayingConfig.Style.Hotbar) { - gui.setNowPlaying(text); - } - } -} diff --git a/common/src/main/java/com/github/scotsguy/nowplaying/NowPlaying.java b/common/src/main/java/com/github/scotsguy/nowplaying/NowPlaying.java index 893f7d4..9c85cf8 100644 --- a/common/src/main/java/com/github/scotsguy/nowplaying/NowPlaying.java +++ b/common/src/main/java/com/github/scotsguy/nowplaying/NowPlaying.java @@ -1,13 +1,14 @@ package com.github.scotsguy.nowplaying; -import me.shedaniel.autoconfig.AutoConfig; -import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import com.github.scotsguy.nowplaying.config.Config; +import com.github.scotsguy.nowplaying.util.ModLogger; public class NowPlaying { + public static final String MOD_ID = "nowplaying"; + public static final String MOD_NAME = "NowPlaying"; + public static final ModLogger LOG = new ModLogger(MOD_NAME); + public static void init() { - AutoConfig.register(NowPlayingConfig.class, JanksonConfigSerializer::new); + Config.getAndSave(); } } diff --git a/common/src/main/java/com/github/scotsguy/nowplaying/NowPlayingConfig.java b/common/src/main/java/com/github/scotsguy/nowplaying/NowPlayingConfig.java deleted file mode 100644 index ecb0fc6..0000000 --- a/common/src/main/java/com/github/scotsguy/nowplaying/NowPlayingConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.github.scotsguy.nowplaying; - -import me.shedaniel.autoconfig.ConfigData; -import me.shedaniel.autoconfig.annotation.Config; -import me.shedaniel.autoconfig.annotation.ConfigEntry; -import me.shedaniel.clothconfig2.gui.entries.SelectionListEntry; -import org.jetbrains.annotations.NotNull; - -@Config(name = "now-playing") -@SuppressWarnings("unused") -public class NowPlayingConfig implements ConfigData { - @ConfigEntry.Gui.Tooltip - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public Style musicStyle = Style.Toast; - - @ConfigEntry.Gui.Tooltip - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public Style jukeboxStyle = Style.Hotbar; - - @ConfigEntry.Gui.Tooltip - public boolean silenceWoosh = false; - - public enum Style implements SelectionListEntry.Translatable { - Hotbar { - @Override - public @NotNull String getKey() { - return "now_playing.config.style.hotbar"; - } - }, - Toast { - @Override - public @NotNull String getKey() { - return "now_playing.config.style.toast"; - } - }, - Disabled { - @Override - public @NotNull String getKey() { - return "now_playing.config.style.disabled"; - } - } - } -} diff --git a/common/src/main/java/com/github/scotsguy/nowplaying/NowPlayingListener.java b/common/src/main/java/com/github/scotsguy/nowplaying/NowPlayingListener.java deleted file mode 100644 index d701681..0000000 --- a/common/src/main/java/com/github/scotsguy/nowplaying/NowPlayingListener.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.github.scotsguy.nowplaying; - -import me.shedaniel.autoconfig.AutoConfig; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.sounds.SoundInstance; -import net.minecraft.client.sounds.SoundEventListener; -import net.minecraft.client.sounds.WeighedSoundEvents; -import net.minecraft.network.chat.Component; -import net.minecraft.sounds.SoundSource; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.RecordItem; - -@Environment(EnvType.CLIENT) -public class NowPlayingListener implements SoundEventListener { - @Override - public void onPlaySound(SoundInstance sound, WeighedSoundEvents soundSet) { - if (sound.getSource() == SoundSource.MUSIC) { - Component name = Util.getSoundName(sound); - if (name == null) return; - - NowPlayingConfig config = AutoConfig.getConfigHolder(NowPlayingConfig.class).getConfig(); - - if (config.musicStyle == NowPlayingConfig.Style.Toast) { - Minecraft.getInstance().getToasts().addToast(new NowPlayingToast(name)); - } else if (config.musicStyle == NowPlayingConfig.Style.Hotbar) { - Minecraft.getInstance().gui.setOverlayMessage(Component.translatable("record.nowPlaying", name), true); - } - } else if (sound.getSource() == SoundSource.RECORDS) { - NowPlayingConfig config = AutoConfig.getConfigHolder(NowPlayingConfig.class).getConfig(); - if (config.jukeboxStyle != NowPlayingConfig.Style.Toast) return; - - RecordItem disc = Util.getDiscFromSound(sound); - if (disc == null) return; - - Minecraft.getInstance().getToasts().addToast(new NowPlayingToast(disc.getDisplayName(), new ItemStack(disc))); - - } - - } -} diff --git a/common/src/main/java/com/github/scotsguy/nowplaying/config/Config.java b/common/src/main/java/com/github/scotsguy/nowplaying/config/Config.java new file mode 100644 index 0000000..ce566cc --- /dev/null +++ b/common/src/main/java/com/github/scotsguy/nowplaying/config/Config.java @@ -0,0 +1,125 @@ +package com.github.scotsguy.nowplaying.config; + +import com.github.scotsguy.nowplaying.NowPlaying; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; + +import static com.github.scotsguy.nowplaying.util.Localization.localized; + +public class Config { + private static final Path DIR_PATH = Path.of("config"); + private static final String FILE_NAME = NowPlaying.MOD_ID + ".json"; + private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + + + // Options + + public final Options options = new Options(); + + public static class Options { + public static final Style defaultMusicStyle = Style.Toast; + public static final Style defaultJukeboxStyle = Style.Hotbar; + public static final boolean defaultSilenceWoosh = true; + public static final boolean defaultSimpleToast = false; + + public Style musicStyle = defaultMusicStyle; + public Style jukeboxStyle = defaultJukeboxStyle; + public boolean silenceWoosh = defaultSilenceWoosh; + public boolean simpleToast = defaultSimpleToast; + + public enum Style { + Toast, + Hotbar, + Disabled; + + public static Component name(Enum