From a943cc93895df0deddab8d44a0456ea00a357ced Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Sun, 11 Jul 2021 01:55:49 +0200 Subject: [PATCH] Cleanup project --- .editorconfig | 311 ++++++++++++++++++ .gitignore | 9 +- EpicVouchers.iml | 36 -- LICENSE | 2 +- Read_this_before_your_first_use.txt | 20 -- pom.xml | 66 ++-- .../songoda/epicvouchers/EpicVouchers.java | 14 +- .../epicvouchers/commands/CommandEditor.java | 1 - .../commands/CommandEpicVouchers.java | 1 - .../epicvouchers/commands/CommandForce.java | 2 - .../commands/CommandForceAll.java | 1 - .../epicvouchers/commands/CommandGive.java | 3 - .../epicvouchers/commands/CommandGiveAll.java | 6 - .../epicvouchers/commands/CommandList.java | 3 - .../epicvouchers/commands/CommandReload.java | 1 - .../epicvouchers/events/ForceRedeemEvent.java | 5 +- .../epicvouchers/handlers/Connections.java | 11 +- .../epicvouchers/libraries/ItemBuilder.java | 9 +- .../libraries/inventory/FastInv.java | 48 ++- .../libraries/inventory/IconInv.java | 46 ++- .../libraries/inventory/icons/Icon.java | 6 +- .../inventory/icons/ListEntryIcon.java | 16 +- .../libraries/inventory/icons/StringIcon.java | 5 +- .../inventory/icons/ToggleableIcon.java | 2 +- .../listeners/PlayerCommandListener.java | 5 +- .../listeners/PlayerInteractListener.java | 3 +- .../epicvouchers/menus/ActionMenu.java | 1 - .../epicvouchers/menus/ConfirmMenu.java | 2 - .../epicvouchers/menus/OptionMenu.java | 9 +- .../epicvouchers/menus/VoucherEditorMenu.java | 6 +- .../epicvouchers/menus/VoucherMenu.java | 2 - .../menus/sub/action/GiveMenu.java | 2 +- .../menus/sub/editor/EffectsMenu.java | 1 - .../menus/sub/editor/ParticlesMenu.java | 1 - .../menus/sub/editor/SetItemMenu.java | 2 - .../menus/sub/editor/StringListMenu.java | 12 +- .../menus/sub/editor/TitlesMenu.java | 1 - .../epicvouchers/settings/Settings.java | 3 +- .../com/songoda/epicvouchers/utils/Pair.java | 32 +- .../epicvouchers/voucher/CoolDownManager.java | 7 +- .../songoda/epicvouchers/voucher/Voucher.java | 4 +- .../epicvouchers/voucher/VoucherManager.java | 5 +- src/main/resources/plugin.yml | 17 +- src/main/resources/vouchers.yml | 2 +- 44 files changed, 507 insertions(+), 234 deletions(-) create mode 100644 .editorconfig delete mode 100644 EpicVouchers.iml delete mode 100644 Read_this_before_your_first_use.txt diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9737e6f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,311 @@ +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +# max_line_length = 120 +tab_width = 4 +trim_trailing_whitespace = true +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_visual_guides = none +ij_wrap_on_typing = false + +[*.java] +ij_smart_tabs = true +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_records = true +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_builder_methods = none +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 = 15 +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 = true +ij_java_doc_add_blank_line_after_return = true +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 = 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 = 0 +ij_java_keep_blank_lines_between_package_declaration_and_header = 0 +ij_java_keep_blank_lines_in_code = 1 +ij_java_keep_blank_lines_in_declarations = 1 +ij_java_keep_builder_methods_indents = false +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 = 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_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 = 9 +ij_java_new_line_after_lparen_in_record_header = false +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_record_components_wrap = normal +ij_java_repeat_synchronized = true +ij_java_replace_instanceof_and_cast = true +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_rparen_on_new_line_in_record_header = false +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 = false +ij_java_spaces_within_braces = true +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_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_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 + +[*.properties] +ij_properties_align_group_field_declarations = false +ij_properties_keep_blank_lines = false +ij_properties_key_value_delimiter = equals +ij_properties_spaces_around_key_value_delimiter = 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 + +[{*.ant, *.fxml, *.jhm, *.jnlp, *.jrxml, *.pom, *.rng, *.tld, *.wsdl, *.xml, *.xsd, *.xsl, *.xslt, *.xul}] +ij_xml_align_attributes = true +ij_xml_align_text = false +ij_xml_attribute_wrap = normal +ij_xml_block_comment_at_first_column = true +ij_xml_keep_blank_lines = 2 +ij_xml_keep_indents_on_empty_lines = false +ij_xml_keep_line_breaks = true +ij_xml_keep_line_breaks_in_text = true +ij_xml_keep_whitespaces = false +ij_xml_keep_whitespaces_around_cdata = preserve +ij_xml_keep_whitespaces_inside_cdata = false +ij_xml_line_comment_at_first_column = true +ij_xml_space_after_tag_name = false +ij_xml_space_around_equals_in_attribute = false +ij_xml_space_inside_empty_tag = false +ij_xml_text_wrap = normal + +[{*.markdown, *.md}] +indent_size = 2 +tab_width = 2 +ij_markdown_force_one_space_after_blockquote_symbol = true +ij_markdown_force_one_space_after_header_symbol = true +ij_markdown_force_one_space_after_list_bullet = true +ij_markdown_force_one_space_between_words = true +ij_markdown_keep_indents_on_empty_lines = false +ij_markdown_max_lines_around_block_elements = 1 +ij_markdown_max_lines_around_header = 1 +ij_markdown_max_lines_between_paragraphs = 1 +ij_markdown_min_lines_around_block_elements = 1 +ij_markdown_min_lines_around_header = 1 +ij_markdown_min_lines_between_paragraphs = 1 + +[{*.yaml, *.yml, *.lang}] +indent_size = 2 +ij_yaml_align_values_properties = do_not_align +ij_yaml_autoinsert_sequence_marker = true +ij_yaml_block_mapping_on_new_line = false +ij_yaml_indent_sequence_value = true +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true +ij_yaml_sequence_on_new_line = false +ij_yaml_space_before_colon = false +ij_yaml_spaces_within_braces = true +ij_yaml_spaces_within_brackets = true diff --git a/.gitignore b/.gitignore index 823932a..600a1f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -\.idea -\target -EpicVouchers.iml -dependency-reduced-pom.xml +/target/ + +# JetBrains IDEs +/.idea/ +*.iml diff --git a/EpicVouchers.iml b/EpicVouchers.iml deleted file mode 100644 index 997ec0c..0000000 --- a/EpicVouchers.iml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - SPIGOT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/LICENSE b/LICENSE index 2ddfa07..d429552 100644 --- a/LICENSE +++ b/LICENSE @@ -6,4 +6,4 @@ The same distribution rights and limitations above shall similarly apply to any The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Read_this_before_your_first_use.txt b/Read_this_before_your_first_use.txt deleted file mode 100644 index 181fc32..0000000 --- a/Read_this_before_your_first_use.txt +++ /dev/null @@ -1,20 +0,0 @@ -Hey loves, - -Thanks for downloading our plugin ^_^ In order to -run it you will need a plugin called arconix. It -basically takes a bunch of methods that we use all -over the place throughout our plugin lineup and -stores it in one place so we don't have to write -new code every time we need to get something simple -done. So make sure to stay up to date with the latest -updates for it. - -Link to download: -https://gitlab.com/Songoda/Arconix/-/jobs/artifacts/master/download?job=build - -If you need help you can always join our -discord in which is listed at the bottom of all of -our plugin pages. - -Enjoy <3 -Brianna & The Songoda Team. \ No newline at end of file diff --git a/pom.xml b/pom.xml index 49d5157..ebff2c4 100644 --- a/pom.xml +++ b/pom.xml @@ -1,47 +1,45 @@ - + + + 4.0.0 + com.songoda EpicVouchers - 4.0.0 2.1.21 + + EpicVouchers + Enhance your server with awesome customizable vouchers with a lot of features. + https://songoda.com/marketplace/product/25 + + + 1.8 + 8 + + UTF-8 + + clean install EpicVouchers-${project.version} + org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + 3.8.1 + - 1.8 - 1.8 - - - - com.google.code.maven-replacer-plugin - replacer - 1.5.3 - - - prepare-package - - replace - - - - - ${project.build.directory}/classes/plugin.yml - - - maven-version-number - ${project.version} - - + ${java.version} + ${java.version} + org.apache.maven.plugins maven-shade-plugin 3.3.0-SNAPSHOT + shaded @@ -49,14 +47,17 @@ shade + false false + com.songoda:SongodaCore + *:* @@ -67,6 +68,7 @@ + com.songoda.core @@ -78,6 +80,7 @@ + src/main/resources @@ -85,18 +88,21 @@ + apache.snapshots https://repository.apache.org/snapshots/ + - public + songoda-public https://repo.songoda.com/repository/public/ + org.spigotmc @@ -104,16 +110,18 @@ 1.17 provided + com.songoda SongodaCore LATEST compile + org.projectlombok lombok - 1.18.2 + 1.18.20 provided diff --git a/src/main/java/com/songoda/epicvouchers/EpicVouchers.java b/src/main/java/com/songoda/epicvouchers/EpicVouchers.java index 1b04e0b..6d9486b 100644 --- a/src/main/java/com/songoda/epicvouchers/EpicVouchers.java +++ b/src/main/java/com/songoda/epicvouchers/EpicVouchers.java @@ -6,7 +6,14 @@ import com.songoda.core.commands.CommandManager; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.configuration.Config; import com.songoda.core.gui.GuiManager; -import com.songoda.epicvouchers.commands.*; +import com.songoda.epicvouchers.commands.CommandEditor; +import com.songoda.epicvouchers.commands.CommandEpicVouchers; +import com.songoda.epicvouchers.commands.CommandForce; +import com.songoda.epicvouchers.commands.CommandForceAll; +import com.songoda.epicvouchers.commands.CommandGive; +import com.songoda.epicvouchers.commands.CommandGiveAll; +import com.songoda.epicvouchers.commands.CommandList; +import com.songoda.epicvouchers.commands.CommandReload; import com.songoda.epicvouchers.handlers.Connections; import com.songoda.epicvouchers.libraries.inventory.FastInv; import com.songoda.epicvouchers.libraries.inventory.IconInv; @@ -27,7 +34,6 @@ import java.util.Collections; import java.util.List; public class EpicVouchers extends SongodaPlugin { - private static EpicVouchers INSTANCE; private final GuiManager guiManager = new GuiManager(this); @@ -37,7 +43,7 @@ public class EpicVouchers extends SongodaPlugin { private Connections connections; private CoolDownManager coolDowns; private VoucherExecutor voucherExecutor; - private Config vouchersConfig = new Config(this, "vouchers.yml"); + private final Config vouchersConfig = new Config(this, "vouchers.yml"); public static EpicVouchers getInstance() { return INSTANCE; @@ -241,4 +247,4 @@ public class EpicVouchers extends SongodaPlugin { public GuiManager getGuiManager() { return guiManager; } -} \ No newline at end of file +} diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandEditor.java b/src/main/java/com/songoda/epicvouchers/commands/CommandEditor.java index 216dd78..d50de7b 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandEditor.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandEditor.java @@ -9,7 +9,6 @@ import org.bukkit.entity.Player; import java.util.List; public class CommandEditor extends AbstractCommand { - final EpicVouchers instance; public CommandEditor(EpicVouchers instance) { diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandEpicVouchers.java b/src/main/java/com/songoda/epicvouchers/commands/CommandEpicVouchers.java index f52de29..3867759 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandEpicVouchers.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandEpicVouchers.java @@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender; import java.util.List; public class CommandEpicVouchers extends AbstractCommand { - final EpicVouchers instance; public CommandEpicVouchers(EpicVouchers instance) { diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandForce.java b/src/main/java/com/songoda/epicvouchers/commands/CommandForce.java index d11186b..650c294 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandForce.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandForce.java @@ -8,14 +8,12 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; public class CommandForce extends AbstractCommand { - final EpicVouchers instance; public CommandForce(EpicVouchers instance) { diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandForceAll.java b/src/main/java/com/songoda/epicvouchers/commands/CommandForceAll.java index 7b78059..fc9e713 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandForceAll.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandForceAll.java @@ -12,7 +12,6 @@ import java.util.List; import java.util.stream.Collectors; public class CommandForceAll extends AbstractCommand { - final EpicVouchers instance; public CommandForceAll(EpicVouchers instance) { diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandGive.java b/src/main/java/com/songoda/epicvouchers/commands/CommandGive.java index ad7baf8..b000dd6 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandGive.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandGive.java @@ -2,21 +2,18 @@ package com.songoda.epicvouchers.commands; import com.songoda.core.commands.AbstractCommand; import com.songoda.epicvouchers.EpicVouchers; -import com.songoda.epicvouchers.menus.VoucherMenu; import com.songoda.epicvouchers.voucher.Voucher; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; public class CommandGive extends AbstractCommand { - final EpicVouchers instance; public CommandGive(EpicVouchers instance) { diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandGiveAll.java b/src/main/java/com/songoda/epicvouchers/commands/CommandGiveAll.java index eea6858..fd23c1a 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandGiveAll.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandGiveAll.java @@ -3,19 +3,13 @@ package com.songoda.epicvouchers.commands; import com.songoda.core.commands.AbstractCommand; import com.songoda.epicvouchers.EpicVouchers; import com.songoda.epicvouchers.voucher.Voucher; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; public class CommandGiveAll extends AbstractCommand { - final EpicVouchers instance; public CommandGiveAll(EpicVouchers instance) { diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandList.java b/src/main/java/com/songoda/epicvouchers/commands/CommandList.java index e44674c..ac7f62d 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandList.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandList.java @@ -2,16 +2,13 @@ package com.songoda.epicvouchers.commands; import com.songoda.core.commands.AbstractCommand; import com.songoda.epicvouchers.EpicVouchers; -import com.songoda.epicvouchers.menus.VoucherMenu; import com.songoda.epicvouchers.voucher.Voucher; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import java.util.List; import java.util.stream.Collectors; public class CommandList extends AbstractCommand { - final EpicVouchers instance; public CommandList(EpicVouchers instance) { diff --git a/src/main/java/com/songoda/epicvouchers/commands/CommandReload.java b/src/main/java/com/songoda/epicvouchers/commands/CommandReload.java index d49e155..f1c458b 100644 --- a/src/main/java/com/songoda/epicvouchers/commands/CommandReload.java +++ b/src/main/java/com/songoda/epicvouchers/commands/CommandReload.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import java.util.List; public class CommandReload extends AbstractCommand { - final EpicVouchers instance; public CommandReload(EpicVouchers instance) { diff --git a/src/main/java/com/songoda/epicvouchers/events/ForceRedeemEvent.java b/src/main/java/com/songoda/epicvouchers/events/ForceRedeemEvent.java index ae098bc..639a177 100644 --- a/src/main/java/com/songoda/epicvouchers/events/ForceRedeemEvent.java +++ b/src/main/java/com/songoda/epicvouchers/events/ForceRedeemEvent.java @@ -7,7 +7,6 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; public class ForceRedeemEvent extends Event implements Cancellable { - private static final HandlerList handlers = new HandlerList(); private final Player player; @@ -48,6 +47,7 @@ public class ForceRedeemEvent extends Event implements Cancellable { this.cancelled = cancelled; } + @Override public HandlerList getHandlers() { return handlers; } @@ -55,5 +55,4 @@ public class ForceRedeemEvent extends Event implements Cancellable { public static HandlerList getHandlerList() { return handlers; } - -} \ No newline at end of file +} diff --git a/src/main/java/com/songoda/epicvouchers/handlers/Connections.java b/src/main/java/com/songoda/epicvouchers/handlers/Connections.java index 09818c5..759eed2 100644 --- a/src/main/java/com/songoda/epicvouchers/handlers/Connections.java +++ b/src/main/java/com/songoda/epicvouchers/handlers/Connections.java @@ -4,10 +4,13 @@ import com.songoda.core.utils.TextUtils; import com.songoda.epicvouchers.EpicVouchers; import org.bukkit.entity.Player; -import java.sql.*; +import java.sql.Connection; +import java.sql.Date; +import java.sql.DriverManager; +import java.sql.Statement; +import java.sql.Timestamp; public class Connections { - private final EpicVouchers instance; private Connection connection; @@ -26,7 +29,6 @@ public class Connections { String mysqlUsername = instance.getConfig().getString("Database.Username"); String mysqlPassword = instance.getConfig().getString("Database.Password"); - connection = DriverManager.getConnection("jdbc:mysql://" + mysqlIP + ":" + mysqlPort + "/" + mysqlDatabase + "?useSSL=true?autoReconnect=true", mysqlUsername, mysqlPassword); System.out.println(TextUtils.formatText("&fSuccessfully created a connection with MySQL.")); } catch (Exception error) { @@ -66,5 +68,4 @@ public class Connections { error.printStackTrace(); } } - -} \ No newline at end of file +} diff --git a/src/main/java/com/songoda/epicvouchers/libraries/ItemBuilder.java b/src/main/java/com/songoda/epicvouchers/libraries/ItemBuilder.java index f99affd..6585e6b 100644 --- a/src/main/java/com/songoda/epicvouchers/libraries/ItemBuilder.java +++ b/src/main/java/com/songoda/epicvouchers/libraries/ItemBuilder.java @@ -7,7 +7,11 @@ import org.bukkit.block.banner.Pattern; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.*; +import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -18,13 +22,12 @@ import java.util.Set; /** * A complete {@link ItemStack} inventory for FastInv (only works on 1.8+). - * + *

* The project is on GitHub * * @author MrMicky */ public class ItemBuilder { - private final ItemStack item; private ItemMeta meta; diff --git a/src/main/java/com/songoda/epicvouchers/libraries/inventory/FastInv.java b/src/main/java/com/songoda/epicvouchers/libraries/inventory/FastInv.java index eaeb272..f114ece 100644 --- a/src/main/java/com/songoda/epicvouchers/libraries/inventory/FastInv.java +++ b/src/main/java/com/songoda/epicvouchers/libraries/inventory/FastInv.java @@ -4,7 +4,11 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.*; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; @@ -25,13 +29,12 @@ import java.util.Set; * @version 2.0.3 - Now supports async operations */ public class FastInv implements InventoryHolder { - private static Plugin plugin = null; private boolean cancelTasksOnClose = true, cancelled = true; - private Set closeListeners = new HashSet<>(); - private Set clickListeners = new HashSet<>(); - private Map itemListeners = new HashMap<>(); - private Set tasks = new HashSet<>(); + private final Set closeListeners = new HashSet<>(); + private final Set clickListeners = new HashSet<>(); + private final Map itemListeners = new HashMap<>(); + private final Set tasks = new HashSet<>(); private Inventory inventory; /** @@ -67,6 +70,7 @@ public class FastInv implements InventoryHolder { * * @param type The type of the menus. * @param title The title of the menus. + * * @throws IllegalStateException if FastInv is not init with FastInv.init(Plugin plugin) */ public FastInv(InventoryType type, String title) { @@ -103,6 +107,7 @@ public class FastInv implements InventoryHolder { * Add an {@link ItemStack} to the menus. * * @param item The item to add + * * @return This FastInv instance, for chaining. */ public FastInv addItem(ItemStack item) { @@ -114,6 +119,7 @@ public class FastInv implements InventoryHolder { * * @param item The item to add. * @param listener The {@link FastInvClickListener} for the item. + * * @return This FastInv instance, for chaining. */ public FastInv addItem(ItemStack item, FastInvClickListener listener) { @@ -131,6 +137,7 @@ public class FastInv implements InventoryHolder { * * @param slot The slot of the item. * @param item The item to add. + * * @return This FastInv instance, for chaining. */ public FastInv addItem(int slot, ItemStack item) { @@ -140,8 +147,9 @@ public class FastInv implements InventoryHolder { /** * Add an {@link ItemStack} to the menus on specific slot with a {@link FastInvClickListener} to handle clicks. * - * @param slot The slot of the item. - * @param itemStack The icon to add. + * @param slot The slot of the item. + * @param itemStack The icon to add. + * * @return This FastInv instance, for chaining. */ public FastInv addItem(int slot, ItemStack itemStack, FastInvClickListener listener) { @@ -164,6 +172,7 @@ public class FastInv implements InventoryHolder { * @param slotFrom Starting slot to put the item in. * @param slotTo Ending slot to put the item in. * @param item The item to add. + * * @return This FastInv instance, for chaining. */ public FastInv addItem(int slotFrom, int slotTo, ItemStack item) { @@ -177,6 +186,7 @@ public class FastInv implements InventoryHolder { * @param slotTo Ending slot to put the item in. * @param item The item to add. * @param listener The IconClickListener for the item. + * * @return This FastInv instance, for chaining. */ public FastInv addItem(int slotFrom, int slotTo, ItemStack item, FastInvClickListener listener) { @@ -191,6 +201,7 @@ public class FastInv implements InventoryHolder { * * @param slots The slot of the item. * @param item The item to add. + * * @return This FastInv instance, for chaining. */ public FastInv addItem(int[] slots, ItemStack item) { @@ -201,6 +212,7 @@ public class FastInv implements InventoryHolder { * Add an {@link ItemStack} to the menus on the edges. * * @param item The item to add. + * * @return This FastInv instance, for chaining. */ public FastInv edge(ItemStack item) { @@ -223,6 +235,7 @@ public class FastInv implements InventoryHolder { * @param slots The slots to place the item. * @param item The item to add. * @param listener The IconClickListener for the item. + * * @return This FastInv instance, for chaining. */ public FastInv addItem(int[] slots, ItemStack item, FastInvClickListener listener) { @@ -243,7 +256,7 @@ public class FastInv implements InventoryHolder { return this; } - public FastInv fill(ItemStack itemStack) { + public FastInv fill(ItemStack itemStack) { return fill(itemStack, null); } @@ -251,6 +264,7 @@ public class FastInv implements InventoryHolder { * Add a {@link FastInvCloseListener} to listen on menus close. * * @param listener The {@link FastInvCloseListener} to add. + * * @return This FastInv instance, for chaining. */ public FastInv onClose(FastInvCloseListener listener) { @@ -262,6 +276,7 @@ public class FastInv implements InventoryHolder { * Add a {@link FastInvClickListener} to listen on menus click. * * @param listener The {@link FastInvClickListener} to add. + * * @return This FastInv instance, for chaining. */ public FastInv onClick(FastInvClickListener listener) { @@ -283,6 +298,7 @@ public class FastInv implements InventoryHolder { * * @param period Delay between each run. * @param runnable The {@link Runnable} task to run. + * * @return This FastInv instance, for chaining. */ public FastInv onUpdate(long period, Runnable runnable) { @@ -295,6 +311,7 @@ public class FastInv implements InventoryHolder { * @param delay Ticks to wait before starting the task. * @param period Delay between each run. * @param runnable The {@link Runnable} task to run. + * * @return This FastInv instance, for chaining */ public FastInv onUpdate(long delay, long period, Runnable runnable) { @@ -355,8 +372,8 @@ public class FastInv implements InventoryHolder { public static abstract class FastInvEvent { - private Player player; - private FastInv inventory; + private final Player player; + private final FastInv inventory; private boolean cancelled; FastInvEvent(Player player, FastInv inventory, boolean cancelled) { @@ -404,10 +421,10 @@ public class FastInv implements InventoryHolder { public static class FastInvClickEvent extends FastInvEvent { - private int slot; - private ItemStack item; - private InventoryAction action; - private ClickType clickType; + private final int slot; + private final ItemStack item; + private final InventoryAction action; + private final ClickType clickType; private FastInvClickEvent(Player player, FastInv inventory, int slot, ItemStack item, boolean cancelled, InventoryAction action, ClickType clickType) { @@ -532,6 +549,7 @@ public class FastInv implements InventoryHolder { * Set if the tasks will be cancel on menus close. * * @param cancelTasksOnClose Set if the tasks will be cancel + * * @return This FastInv instance, for chaining. */ public FastInv setCancelTasksOnClose(boolean cancelTasksOnClose) { diff --git a/src/main/java/com/songoda/epicvouchers/libraries/inventory/IconInv.java b/src/main/java/com/songoda/epicvouchers/libraries/inventory/IconInv.java index cbc9463..7521172 100644 --- a/src/main/java/com/songoda/epicvouchers/libraries/inventory/IconInv.java +++ b/src/main/java/com/songoda/epicvouchers/libraries/inventory/IconInv.java @@ -5,7 +5,11 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.*; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; @@ -27,13 +31,12 @@ import java.util.function.Consumer; * @version 2.0.3 - Now supports async operations */ public class IconInv implements InventoryHolder { - private static Plugin plugin = null; private boolean cancelTasksOnClose = true, cancelled = true; - private Set closeListeners = new HashSet<>(); - private Set clickListeners = new HashSet<>(); - private Map itemListeners = new HashMap<>(); - private Set tasks = new HashSet<>(); + private final Set closeListeners = new HashSet<>(); + private final Set clickListeners = new HashSet<>(); + private final Map itemListeners = new HashMap<>(); + private final Set tasks = new HashSet<>(); private Inventory inventory; /** @@ -69,6 +72,7 @@ public class IconInv implements InventoryHolder { * * @param type The type of the menus. * @param title The title of the menus. + * * @throws IllegalStateException if FastInv is not init with FastInv.init(Plugin plugin) */ public IconInv(InventoryType type, String title) { @@ -104,7 +108,8 @@ public class IconInv implements InventoryHolder { /** * Add an {@link ItemStack} to the menus with a {@link IconClickListener} to handle clicks. * - * @param icon The icon to add. + * @param icon The icon to add. + * * @return This FastInv instance, for chaining. */ public IconInv addIcon(Icon icon) { @@ -122,6 +127,7 @@ public class IconInv implements InventoryHolder { * * @param slot The slot of the item. * @param icon The icon to add. + * * @return This FastInv instance, for chaining. */ public IconInv addIcon(int slot, Icon icon) { @@ -139,6 +145,7 @@ public class IconInv implements InventoryHolder { * @param slotFrom Starting slot to put the item in. * @param slotTo Ending slot to put the item in. * @param icon The icon to add. + * * @return This FastInv instance, for chaining. */ public IconInv addIcon(int slotFrom, int slotTo, Icon icon) { @@ -152,6 +159,7 @@ public class IconInv implements InventoryHolder { * Add an {@link ItemStack} to the menus on the edges. * * @param icon The icon to add. + * * @return This FastInv instance, for chaining. */ public IconInv edge(Icon icon) { @@ -171,8 +179,9 @@ public class IconInv implements InventoryHolder { /** * Add an {@link ItemStack} to the menus on multiples slots with a {@link IconClickListener} to handle click. * - * @param slots The slots to place the item. - * @param icon The icon to add. + * @param slots The slots to place the item. + * @param icon The icon to add. + * * @return This FastInv instance, for chaining. */ public IconInv addIcon(int[] slots, Icon icon) { @@ -209,6 +218,7 @@ public class IconInv implements InventoryHolder { * Add a {@link IconInvCloseListener} to listen on menus close. * * @param listener The {@link IconInvCloseListener} to add. + * * @return This FastInv instance, for chaining. */ public IconInv onClose(IconInvCloseListener listener) { @@ -220,6 +230,7 @@ public class IconInv implements InventoryHolder { * Add a {@link IconClickListener} to listen on menus click. * * @param listener The {@link IconClickListener} to add. + * * @return This FastInv instance, for chaining. */ public IconInv onClick(IconClickListener listener) { @@ -232,6 +243,7 @@ public class IconInv implements InventoryHolder { * * @param period Delay between each run. * @param runnable The {@link Runnable} task to run. + * * @return This FastInv instance, for chaining. */ public IconInv onUpdate(long period, Runnable runnable) { @@ -244,6 +256,7 @@ public class IconInv implements InventoryHolder { * @param delay Ticks to wait before starting the task. * @param period Delay between each run. * @param runnable The {@link Runnable} task to run. + * * @return This FastInv instance, for chaining */ public IconInv onUpdate(long delay, long period, Runnable runnable) { @@ -298,6 +311,7 @@ public class IconInv implements InventoryHolder { * Set if the tasks will be cancel on menus close. * * @param cancelTasksOnClose Set if the tasks will be cancel + * * @return This FastInv instance, for chaining. */ public IconInv setCancelTasksOnClose(boolean cancelTasksOnClose) { @@ -314,9 +328,8 @@ public class IconInv implements InventoryHolder { } public static abstract class IconEvent { - - private Player player; - private IconInv inventory; + private final Player player; + private final IconInv inventory; private boolean cancelled; IconEvent(Player player, IconInv inventory, boolean cancelled) { @@ -363,11 +376,10 @@ public class IconInv implements InventoryHolder { } public static class IconClickEvent extends IconEvent { - - private int slot; - private ItemStack item; - private InventoryAction action; - private ClickType clickType; + private final int slot; + private final ItemStack item; + private final InventoryAction action; + private final ClickType clickType; private IconClickEvent(Player player, IconInv inventory, int slot, ItemStack item, boolean cancelled, InventoryAction action, ClickType clickType) { diff --git a/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/Icon.java b/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/Icon.java index 92db81b..669dedc 100644 --- a/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/Icon.java +++ b/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/Icon.java @@ -6,11 +6,11 @@ import org.bukkit.inventory.ItemStack; import java.util.function.Consumer; public class Icon { - private ItemStack itemStack; - private Consumer consumer; + private final ItemStack itemStack; + private final Consumer consumer; public Icon(ItemStack itemStack) { - this(itemStack, event -> {}); + this(itemStack, event -> { }); } public Icon(ItemStack item, Consumer consumer) { diff --git a/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/ListEntryIcon.java b/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/ListEntryIcon.java index 2bf3c44..be3a692 100644 --- a/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/ListEntryIcon.java +++ b/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/ListEntryIcon.java @@ -16,15 +16,17 @@ import static org.bukkit.Material.PAPER; public class ListEntryIcon extends Icon { public ListEntryIcon(EpicVouchers instance, String entry, BiConsumer onRemove, BiConsumer> onEdit) { - super(new ItemBuilder(PAPER).name(YELLOW + entry).lore(GRAY + "Right click to edit", - GRAY + "Left click to remove").build(), event -> { - if (event.getClickType() == ClickType.LEFT) { - onRemove.accept(event.getPlayer(), entry); + super(new ItemBuilder(PAPER) + .name(YELLOW + entry) + .lore(GRAY + "Right click to edit", GRAY + "Left click to remove") + .build(), clickEvent -> { + if (clickEvent.getClickType() == ClickType.LEFT) { + onRemove.accept(clickEvent.getPlayer(), entry); return; } - ChatPrompt.showPrompt(instance, event.getPlayer(), aevent -> { - Bukkit.getScheduler().runTaskLater(instance, () -> onEdit.accept(event.getPlayer(), new Pair<>(entry, aevent.getMessage().trim())), 1L); - }); + ChatPrompt.showPrompt(instance, clickEvent.getPlayer(), + pEvent -> Bukkit.getScheduler().runTaskLater(instance, + () -> onEdit.accept(clickEvent.getPlayer(), new Pair<>(entry, pEvent.getMessage().trim())), 1L)); }); } } diff --git a/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/StringIcon.java b/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/StringIcon.java index 072d4f2..38824bb 100644 --- a/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/StringIcon.java +++ b/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/StringIcon.java @@ -19,7 +19,6 @@ import static org.bukkit.ChatColor.GRAY; import static org.bukkit.ChatColor.WHITE; public class StringIcon extends Icon { - public StringIcon(EpicVouchers instance, String string, String current, BiConsumer consumer) { this(instance, string, current, consumer, s -> true); } @@ -57,10 +56,8 @@ public class StringIcon extends Icon { } event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully set to &r" + msg + "&7.")); Bukkit.getScheduler().runTaskLater(instance, () -> consumer.accept(event.getPlayer(), msg), 1L); - }); + }); } - }); } - } diff --git a/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/ToggleableIcon.java b/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/ToggleableIcon.java index 6be0b2e..f87255f 100644 --- a/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/ToggleableIcon.java +++ b/src/main/java/com/songoda/epicvouchers/libraries/inventory/icons/ToggleableIcon.java @@ -14,7 +14,7 @@ public class ToggleableIcon extends Icon { super(new ItemBuilder(Material.PAPER) .name(ChatColor.YELLOW + displayname) .lore(state ? ChatColor.GREEN + "ENABLED" : ChatColor.RED + "DISABLED") - .build(), event -> {}); + .build(), event -> { }); this.consumer = consumer; } diff --git a/src/main/java/com/songoda/epicvouchers/listeners/PlayerCommandListener.java b/src/main/java/com/songoda/epicvouchers/listeners/PlayerCommandListener.java index 5e47756..856212d 100644 --- a/src/main/java/com/songoda/epicvouchers/listeners/PlayerCommandListener.java +++ b/src/main/java/com/songoda/epicvouchers/listeners/PlayerCommandListener.java @@ -8,7 +8,6 @@ import java.util.HashMap; import java.util.UUID; public class PlayerCommandListener implements Listener { - private static final HashMap commands = new HashMap<>(); @EventHandler @@ -23,8 +22,8 @@ public class PlayerCommandListener implements Listener { public static void addCommand(UUID uuid, String command) { commands.put(uuid, command); } + public static void removeCommand(UUID uuid) { commands.remove(uuid); } - -} \ No newline at end of file +} diff --git a/src/main/java/com/songoda/epicvouchers/listeners/PlayerInteractListener.java b/src/main/java/com/songoda/epicvouchers/listeners/PlayerInteractListener.java index a025972..3aa9107 100644 --- a/src/main/java/com/songoda/epicvouchers/listeners/PlayerInteractListener.java +++ b/src/main/java/com/songoda/epicvouchers/listeners/PlayerInteractListener.java @@ -13,7 +13,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; public class PlayerInteractListener implements Listener { - private final EpicVouchers instance; public PlayerInteractListener(EpicVouchers instance) { @@ -56,4 +55,4 @@ public class PlayerInteractListener implements Listener { voucher.redeemVoucher(event); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/songoda/epicvouchers/menus/ActionMenu.java b/src/main/java/com/songoda/epicvouchers/menus/ActionMenu.java index cf514f4..0cf96be 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/ActionMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/ActionMenu.java @@ -20,7 +20,6 @@ import static org.bukkit.ChatColor.YELLOW; import static org.bukkit.Material.BARRIER; public class ActionMenu extends FastInv { - public ActionMenu(EpicVouchers instance, Voucher voucher) { super(27, "Give menu"); diff --git a/src/main/java/com/songoda/epicvouchers/menus/ConfirmMenu.java b/src/main/java/com/songoda/epicvouchers/menus/ConfirmMenu.java index be04ffd..b573c49 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/ConfirmMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/ConfirmMenu.java @@ -1,7 +1,6 @@ package com.songoda.epicvouchers.menus; import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.ServerVersion; import com.songoda.epicvouchers.EpicVouchers; import com.songoda.epicvouchers.libraries.ItemBuilder; import com.songoda.epicvouchers.libraries.inventory.FastInv; @@ -13,7 +12,6 @@ import static org.bukkit.enchantments.Enchantment.DURABILITY; import static org.bukkit.inventory.ItemFlag.HIDE_ENCHANTS; public class ConfirmMenu extends FastInv { - public ConfirmMenu(EpicVouchers instance, Runnable success, Runnable failure) { super(27, instance.getLocale().getMessage("interface.confirmsettings.title").getMessage()); diff --git a/src/main/java/com/songoda/epicvouchers/menus/OptionMenu.java b/src/main/java/com/songoda/epicvouchers/menus/OptionMenu.java index 8a8552c..cd70d07 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/OptionMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/OptionMenu.java @@ -1,7 +1,6 @@ package com.songoda.epicvouchers.menus; import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.utils.TextUtils; import com.songoda.epicvouchers.EpicVouchers; import com.songoda.epicvouchers.libraries.ItemBuilder; @@ -9,14 +8,15 @@ import com.songoda.epicvouchers.libraries.inventory.FastInv; import com.songoda.epicvouchers.menus.sub.editor.SetItemMenu; import com.songoda.epicvouchers.voucher.Voucher; import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; import static org.bukkit.ChatColor.GRAY; import static org.bukkit.ChatColor.YELLOW; -import static org.bukkit.Material.*; +import static org.bukkit.Material.BARRIER; +import static org.bukkit.Material.BOOK; +import static org.bukkit.Material.FEATHER; +import static org.bukkit.Material.STONE; public class OptionMenu extends FastInv { - public OptionMenu(EpicVouchers instance, Voucher voucher) { super(27, "Options: " + voucher.getKey()); @@ -45,5 +45,4 @@ public class OptionMenu extends FastInv { fill(new ItemBuilder(CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem()).name(ChatColor.RESET.toString()).build()); } - } diff --git a/src/main/java/com/songoda/epicvouchers/menus/VoucherEditorMenu.java b/src/main/java/com/songoda/epicvouchers/menus/VoucherEditorMenu.java index 810fb9d..c76fe8c 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/VoucherEditorMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/VoucherEditorMenu.java @@ -63,7 +63,7 @@ public class VoucherEditorMenu extends IconInv { })); addIcon(11, new StringIcon(instance, "Material", voucher.getMaterial().toString(), (player, editString) -> { - if(editString.contains(":")) { + if (editString.contains(":")) { voucher.setData(Short.parseShort(editString.split(":")[1])); voucher.setMaterial(Material.valueOf(editString.split(":")[0])); } else { @@ -72,11 +72,11 @@ public class VoucherEditorMenu extends IconInv { reopen(player); }, string -> { - if (string.isEmpty()) { + if (string.isEmpty()) { return false; } - if(string.contains(":") && string.split(":").length == 2) { + if (string.contains(":") && string.split(":").length == 2) { String[] split = string.split(":"); return Material.matchMaterial(split[0]) != null && StringUtils.isNumeric(split[1]); } diff --git a/src/main/java/com/songoda/epicvouchers/menus/VoucherMenu.java b/src/main/java/com/songoda/epicvouchers/menus/VoucherMenu.java index 4f794d8..2e1ed66 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/VoucherMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/VoucherMenu.java @@ -15,7 +15,6 @@ import org.bukkit.inventory.ItemStack; import static org.bukkit.Material.PAPER; public class VoucherMenu extends IconInv { - public VoucherMenu(EpicVouchers instance) { super((int) (Math.ceil(instance.getVoucherManager().getVouchers().size() / 9.0) * 9 + (instance.getVoucherManager().getVouchers().size() % 9 == 0 ? 9 : 0)), "Vouchers"); @@ -54,5 +53,4 @@ public class VoucherMenu extends IconInv { new ItemStack(Material.valueOf("GRAY_STAINED_GLASS_PANE")) : new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 7)).name(ChatColor.RESET.toString()).build())); } - } diff --git a/src/main/java/com/songoda/epicvouchers/menus/sub/action/GiveMenu.java b/src/main/java/com/songoda/epicvouchers/menus/sub/action/GiveMenu.java index c731546..99935c8 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/sub/action/GiveMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/sub/action/GiveMenu.java @@ -12,4 +12,4 @@ public class GiveMenu extends PlayersMenu { public GiveMenu(EpicVouchers instance, Voucher voucher) { super(instance, voucher, "Give Menu", (who, player) -> voucher.give(who, Collections.singletonList(player), 1), new ArrayList<>(Bukkit.getOnlinePlayers())); } -} \ No newline at end of file +} diff --git a/src/main/java/com/songoda/epicvouchers/menus/sub/editor/EffectsMenu.java b/src/main/java/com/songoda/epicvouchers/menus/sub/editor/EffectsMenu.java index 4dce9f2..e43753b 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/sub/editor/EffectsMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/sub/editor/EffectsMenu.java @@ -35,6 +35,5 @@ public class EffectsMenu extends IconInv { .name(YELLOW + "Return") .lore(GRAY + "Return to the editor") .build(), event -> new VoucherEditorMenu(instance, voucher).open(event.getPlayer())); - } } diff --git a/src/main/java/com/songoda/epicvouchers/menus/sub/editor/ParticlesMenu.java b/src/main/java/com/songoda/epicvouchers/menus/sub/editor/ParticlesMenu.java index 2f16ee4..ab91f79 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/sub/editor/ParticlesMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/sub/editor/ParticlesMenu.java @@ -30,6 +30,5 @@ public class ParticlesMenu extends IconInv { .name(YELLOW + "Return") .lore(GRAY + "Return to the editor") .build(), event -> new VoucherEditorMenu(instance, voucher).open(event.getPlayer())); - } } diff --git a/src/main/java/com/songoda/epicvouchers/menus/sub/editor/SetItemMenu.java b/src/main/java/com/songoda/epicvouchers/menus/sub/editor/SetItemMenu.java index 06a443e..265b6db 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/sub/editor/SetItemMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/sub/editor/SetItemMenu.java @@ -15,7 +15,6 @@ import static org.bukkit.ChatColor.GRAY; import static org.bukkit.ChatColor.YELLOW; public class SetItemMenu extends FastInv { - public SetItemMenu(EpicVouchers instance, Voucher voucher) { super(27, "Set item"); @@ -74,6 +73,5 @@ public class SetItemMenu extends FastInv { new OptionMenu(instance, voucher).open(event.getPlayer()); }); - } } diff --git a/src/main/java/com/songoda/epicvouchers/menus/sub/editor/StringListMenu.java b/src/main/java/com/songoda/epicvouchers/menus/sub/editor/StringListMenu.java index 923162b..f54f4e1 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/sub/editor/StringListMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/sub/editor/StringListMenu.java @@ -14,11 +14,13 @@ import org.bukkit.Material; import java.util.List; import java.util.stream.Collectors; -import static org.bukkit.ChatColor.*; +import static org.bukkit.ChatColor.DARK_GRAY; +import static org.bukkit.ChatColor.GRAY; +import static org.bukkit.ChatColor.GREEN; +import static org.bukkit.ChatColor.YELLOW; import static org.bukkit.Material.PAPER; public class StringListMenu extends IconInv { - public StringListMenu(EpicVouchers instance, String key, List list, String toEdit, Voucher voucher) { super((int) ((list.isEmpty() ? 9 : Math.ceil(list.size() / 9.0) * 9) + 9), key); int size = getInventory().getSize(); @@ -35,10 +37,9 @@ public class StringListMenu extends IconInv { addIcon(size - 1, new ItemBuilder(PAPER).name(GREEN + "Add to list").build(), event -> { ChatPrompt.showPrompt(instance, event.getPlayer(), TextUtils.formatText("Enter a new value."), aevent -> { - list.add(aevent.getMessage().trim()); - voucher.saveSetting(key.toLowerCase(), list); + list.add(aevent.getMessage().trim()); + voucher.saveSetting(key.toLowerCase(), list); Bukkit.getScheduler().runTaskLater(instance, () -> new StringListMenu(instance, key, list, toEdit, voucher).open(event.getPlayer()), 1L); - }); }); @@ -54,6 +55,5 @@ public class StringListMenu extends IconInv { new StringListMenu(instance, key, list, toEdit, voucher).open(player); })); } - } } diff --git a/src/main/java/com/songoda/epicvouchers/menus/sub/editor/TitlesMenu.java b/src/main/java/com/songoda/epicvouchers/menus/sub/editor/TitlesMenu.java index 369a00f..253663d 100644 --- a/src/main/java/com/songoda/epicvouchers/menus/sub/editor/TitlesMenu.java +++ b/src/main/java/com/songoda/epicvouchers/menus/sub/editor/TitlesMenu.java @@ -45,6 +45,5 @@ public class TitlesMenu extends IconInv { .name(YELLOW + "Return") .lore(GRAY + "Return to the editor") .build(), event -> new VoucherEditorMenu(instance, voucher).open(event.getPlayer())); - } } diff --git a/src/main/java/com/songoda/epicvouchers/settings/Settings.java b/src/main/java/com/songoda/epicvouchers/settings/Settings.java index 1398a15..1034b6a 100644 --- a/src/main/java/com/songoda/epicvouchers/settings/Settings.java +++ b/src/main/java/com/songoda/epicvouchers/settings/Settings.java @@ -9,7 +9,6 @@ import org.bukkit.event.Listener; * Created by songo on 6/4/2017. */ public class Settings implements Listener { - static final Config config = EpicVouchers.getInstance().getCoreConfig(); public static final ConfigSetting FILL_GLASS = new ConfigSetting(config, "Interface.Fill Interfaces With Glass", true); @@ -31,4 +30,4 @@ public class Settings implements Listener { config.setAutoremove(true).setAutosave(true); config.saveChanges(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/songoda/epicvouchers/utils/Pair.java b/src/main/java/com/songoda/epicvouchers/utils/Pair.java index 177fa55..e4a34bc 100644 --- a/src/main/java/com/songoda/epicvouchers/utils/Pair.java +++ b/src/main/java/com/songoda/epicvouchers/utils/Pair.java @@ -1,20 +1,22 @@ package com.songoda.epicvouchers.utils; import java.io.Serializable; +import java.util.Objects; /** *

A convenience class to represent name-value pairs.

+ * * @since JavaFX 2.0 */ -public class Pair implements Serializable{ - +public class Pair implements Serializable { /** * Key of this Pair. */ - private String key; + private final String key; /** * Gets the key for this pair. + * * @return key for this pair */ public String getKey() { return key; } @@ -22,17 +24,19 @@ public class Pair implements Serializable{ /** * Value of this this Pair. */ - private String value; + private final String value; /** * Gets the value for this pair. + * * @return value for this pair */ public String getValue() { return value; } /** * Creates a new pair - * @param key The key for this pair + * + * @param key The key for this pair * @param value The value to use for this pair */ public Pair(String key, String value) { @@ -46,7 +50,7 @@ public class Pair implements Serializable{ * *

The default name/value delimiter '=' is always used.

* - * @return String representation of this Pair + * @return String representation of this Pair */ @Override public String toString() { @@ -83,20 +87,18 @@ public class Pair implements Serializable{ * both the names and values are equal.

* * @param o the Object to test for - * equality with this Pair + * equality with this Pair + * * @return true if the given Object is - * equal to this Pair else false + * equal to this Pair else false */ @Override public boolean equals(Object o) { if (this == o) return true; - if (o instanceof Pair) { - Pair pair = (Pair) o; - if (key != null ? !key.equals(pair.key) : pair.key != null) return false; - if (value != null ? !value.equals(pair.value) : pair.value != null) return false; - return true; - } - return false; + if (o == null || getClass() != o.getClass()) return false; + + Pair pair = (Pair) o; + return Objects.equals(key, pair.key) && Objects.equals(value, pair.value); } } diff --git a/src/main/java/com/songoda/epicvouchers/voucher/CoolDownManager.java b/src/main/java/com/songoda/epicvouchers/voucher/CoolDownManager.java index a8facbe..df4e3aa 100644 --- a/src/main/java/com/songoda/epicvouchers/voucher/CoolDownManager.java +++ b/src/main/java/com/songoda/epicvouchers/voucher/CoolDownManager.java @@ -8,7 +8,6 @@ import java.util.Map; import java.util.UUID; public class CoolDownManager { - private final Map entries = new HashMap<>(); private final EpicVouchers instance; @@ -22,9 +21,9 @@ public class CoolDownManager { } if (voucher.getCoolDown() != 0) { - entries.put(uuid, System.currentTimeMillis() + voucher.getCoolDown() * 1000); + entries.put(uuid, System.currentTimeMillis() + voucher.getCoolDown() * 1000L); } else { - entries.put(uuid, System.currentTimeMillis() + instance.getConfig().getInt("Main.Cooldown Delay") * 1000); + entries.put(uuid, System.currentTimeMillis() + instance.getConfig().getInt("Main.Cooldown Delay") * 1000L); } } @@ -52,4 +51,4 @@ public class CoolDownManager { return (time - System.currentTimeMillis()) / 1000; } -} \ No newline at end of file +} diff --git a/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java b/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java index 861193f..851fb16 100644 --- a/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java +++ b/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java @@ -30,7 +30,6 @@ import static org.bukkit.Material.PAPER; @Accessors(chain = true) public class Voucher { - private final String key; private final EpicVouchers instance; private String permission = ""; @@ -236,8 +235,7 @@ public class Voucher { if (confirm) { new ConfirmMenu(instance, () -> instance.getVoucherExecutor().redeemVoucher(player, this, event.getItem(), true, event), - () -> { - }) + () -> { }) .open(player); } else { instance.getVoucherExecutor().redeemVoucher(player, this, event.getItem(), true, event); diff --git a/src/main/java/com/songoda/epicvouchers/voucher/VoucherManager.java b/src/main/java/com/songoda/epicvouchers/voucher/VoucherManager.java index 09be4ec..9e2c5aa 100644 --- a/src/main/java/com/songoda/epicvouchers/voucher/VoucherManager.java +++ b/src/main/java/com/songoda/epicvouchers/voucher/VoucherManager.java @@ -1,9 +1,10 @@ package com.songoda.epicvouchers.voucher; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; public class VoucherManager { - private final Map registeredVouchers = new HashMap<>(); public Voucher addVoucher(Voucher voucher) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 01d7572..665b45e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,13 +1,16 @@ -name: EpicVouchers -main: com.songoda.epicvouchers.EpicVouchers -version: maven-version-number -author: Songoda -website: https://songoda.host/epicvouchers -description: Enhance your server with awesome customizable vouchers with a lot of features. +name: ${project.name} +description: ${project.description} +version: ${project.version} api-version: 1.13 + +main: com.songoda.epicvouchers.EpicVouchers + +author: Songoda +website: ${project.url} + commands: epicvouchers: description: View information on this plugin. default: true aliases: [ev] - usage: /ev \ No newline at end of file + usage: /ev diff --git a/src/main/resources/vouchers.yml b/src/main/resources/vouchers.yml index a17f82c..0d85345 100644 --- a/src/main/resources/vouchers.yml +++ b/src/main/resources/vouchers.yml @@ -51,4 +51,4 @@ vouchers: effects: effect: "SPEED" amplifier: 2 - duration: 10 \ No newline at end of file + duration: 10