mirror of
https://github.com/songoda/EpicVouchers.git
synced 2024-11-21 17:45:48 +01:00
Merge branch 'development'
This commit is contained in:
commit
e205a07318
301
.editorconfig
301
.editorconfig
@ -1,3 +1,6 @@
|
||||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
@ -10,302 +13,14 @@ 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
|
||||
ij_formatter_tags_enabled = true
|
||||
|
||||
[*.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}]
|
||||
[{*.yaml,*.yml,*.json,*.lang,*.graphqlconfig,*.har,*.jsb2,*.jsb3,*.webmanifest,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config}]
|
||||
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}]
|
||||
|
||||
[{*.markdown,*.md,*.html,*.htm,*.ng,*.sht,*.shtm,*.shtml,*.ts,*.ats,*.js,*.cjs,*.bash,*.sh,*.zsh}]
|
||||
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
|
||||
tab_width = 2
|
||||
|
13
.github/FUNDING.yml
vendored
13
.github/FUNDING.yml
vendored
@ -1,12 +1 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: songoda
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
custom: [ 'https://craftaro.to/+' ]
|
||||
|
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,5 +1,10 @@
|
||||
/target/
|
||||
|
||||
# JetBrains IDEs
|
||||
## JetBrains IDEs
|
||||
/.idea/
|
||||
*.iml
|
||||
|
||||
## Maven
|
||||
/**/target/
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
## Misc.
|
||||
.DS_Store
|
||||
|
110
pom.xml
110
pom.xml
@ -4,77 +4,77 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicVouchers</artifactId>
|
||||
<version>2.2.6</version>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>EpicVouchers-Plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
|
||||
<name>EpicVouchers</name>
|
||||
<description>Enhance your server with awesome customizable vouchers with a lot of features.</description>
|
||||
<url>https://songoda.com/marketplace/product/25</url>
|
||||
<description>Create vouchers that players can claim for rewards with seemingly infinite possibilities</description>
|
||||
<url>https://craftaro.com/marketplace/product/25</url>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<java.release>8</java.release>
|
||||
<maven.compiler.release>8</maven.compiler.release>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>EpicVouchers-${project.version}</finalName>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<version>3.5.0</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:SongodaCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<useDependencyReducedPomInJar>true</useDependencyReducedPomInJar>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.craftaro.core</pattern>
|
||||
<shadedPattern>com.craftaro.epicvouchers.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
<exclude>META-INF/**</exclude>
|
||||
<exclude>LICENSE</exclude>
|
||||
<exclude>LICENSE.**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
|
||||
<filter>
|
||||
<artifact>com.craftaro:CraftaroCore</artifact>
|
||||
<excludeDefaults>false</excludeDefaults>
|
||||
<excludes>
|
||||
<exclude>**/third_party/org/apache/**</exclude>
|
||||
<exclude>**/third_party/net/kyori/**</exclude>
|
||||
<exclude>**/third_party/com/zaxxer/**</exclude>
|
||||
<exclude>**/third_party/org/jooq/**</exclude>
|
||||
<exclude>**/third_party/org/mariadb/**</exclude>
|
||||
<exclude>**/third_party/com/h2database/**</exclude>
|
||||
<exclude>**/third_party/org/h2/**</exclude>
|
||||
<exclude>**/third_party/com/cryptomorin/**</exclude>
|
||||
<exclude>**/third_party/org/reactivestreams/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.songoda.core</pattern>
|
||||
<shadedPattern>${project.groupId}.epicvouchers.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@ -89,21 +89,26 @@
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>apache.snapshots</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>songoda-public</id>
|
||||
<url>https://repo.songoda.com/repository/public/</url>
|
||||
<id>craftaro-minecraft-plugins</id>
|
||||
<url>https://repo.craftaro.com/repository/minecraft-plugins/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>SpigotMC</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>CraftaroCore</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
@ -111,13 +116,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>2.6.19</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
@ -1,31 +1,32 @@
|
||||
package com.songoda.epicvouchers;
|
||||
package com.craftaro.epicvouchers;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
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.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;
|
||||
import com.songoda.epicvouchers.listeners.PlayerCommandListener;
|
||||
import com.songoda.epicvouchers.listeners.PlayerInteractListener;
|
||||
import com.songoda.epicvouchers.settings.Settings;
|
||||
import com.songoda.epicvouchers.utils.Callback;
|
||||
import com.songoda.epicvouchers.utils.ThreadSync;
|
||||
import com.songoda.epicvouchers.voucher.CoolDownManager;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.songoda.epicvouchers.voucher.VoucherExecutor;
|
||||
import com.songoda.epicvouchers.voucher.VoucherManager;
|
||||
import com.craftaro.core.SongodaCore;
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.commands.CommandManager;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.craftaro.core.dependency.Dependency;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.epicvouchers.commands.CommandEditor;
|
||||
import com.craftaro.epicvouchers.commands.CommandEpicVouchers;
|
||||
import com.craftaro.epicvouchers.commands.CommandForce;
|
||||
import com.craftaro.epicvouchers.commands.CommandForceAll;
|
||||
import com.craftaro.epicvouchers.commands.CommandGive;
|
||||
import com.craftaro.epicvouchers.commands.CommandGiveAll;
|
||||
import com.craftaro.epicvouchers.commands.CommandList;
|
||||
import com.craftaro.epicvouchers.commands.CommandReload;
|
||||
import com.craftaro.epicvouchers.handlers.Connections;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.listeners.PlayerCommandListener;
|
||||
import com.craftaro.epicvouchers.listeners.PlayerInteractListener;
|
||||
import com.craftaro.epicvouchers.settings.Settings;
|
||||
import com.craftaro.epicvouchers.utils.Callback;
|
||||
import com.craftaro.epicvouchers.utils.ThreadSync;
|
||||
import com.craftaro.epicvouchers.voucher.CoolDownManager;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.voucher.VoucherExecutor;
|
||||
import com.craftaro.epicvouchers.voucher.VoucherManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -34,11 +35,11 @@ import org.bukkit.plugin.PluginManager;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class EpicVouchers extends SongodaPlugin {
|
||||
private static EpicVouchers INSTANCE;
|
||||
|
||||
private final GuiManager guiManager = new GuiManager(this);
|
||||
private CommandManager commandManager;
|
||||
private VoucherManager voucherManager;
|
||||
@ -48,25 +49,33 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
private VoucherExecutor voucherExecutor;
|
||||
private final Config vouchersConfig = new Config(this, "vouchers.yml");
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link org.bukkit.plugin.java.JavaPlugin#getPlugin(Class)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static EpicVouchers getInstance() {
|
||||
return INSTANCE;
|
||||
return getPlugin(EpicVouchers.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Dependency> getDependencies() {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
connections.closeMySQL();
|
||||
this.connections.closeMySQL();
|
||||
saveVouchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginEnable() {
|
||||
// Run Songoda Updater
|
||||
SongodaCore.registerPlugin(this, 25, CompatibleMaterial.EMERALD);
|
||||
SongodaCore.registerPlugin(this, 25, XMaterial.EMERALD);
|
||||
|
||||
// Setup Config
|
||||
Settings.setupConfig();
|
||||
@ -96,7 +105,7 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
PluginManager manager = Bukkit.getServer().getPluginManager();
|
||||
|
||||
// Listeners
|
||||
guiManager.init();
|
||||
this.guiManager.init();
|
||||
manager.registerEvents(new PlayerInteractListener(this), this);
|
||||
manager.registerEvents(new PlayerCommandListener(), this);
|
||||
}
|
||||
@ -107,13 +116,13 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
saveResource("vouchers.yml", false);
|
||||
}
|
||||
|
||||
synchronized (vouchersConfig) {
|
||||
vouchersConfig.load();
|
||||
synchronized (this.vouchersConfig) {
|
||||
this.vouchersConfig.load();
|
||||
}
|
||||
|
||||
loadVouchersFromFile();
|
||||
|
||||
connections.openMySQL();
|
||||
this.connections.openMySQL();
|
||||
|
||||
// FIXME: Config system needs to be greatly redone and only write changes when changes were made - Maybe even split it into multiple smaler files
|
||||
// Issue https://support.songoda.com/browse/SD-8155 has been hotfixed by writing changes to the file async and blocking the main thread when needed. This requires the use of `synchronized`
|
||||
@ -129,13 +138,13 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
}
|
||||
|
||||
private void loadVouchersFromFile() {
|
||||
synchronized (vouchersConfig) {
|
||||
voucherManager.clearVouchers();
|
||||
synchronized (this.vouchersConfig) {
|
||||
this.voucherManager.clearVouchers();
|
||||
|
||||
if (vouchersConfig.contains("vouchers")) {
|
||||
for (String key : vouchersConfig.getConfigurationSection("vouchers").getKeys(false)) {
|
||||
if (this.vouchersConfig.contains("vouchers")) {
|
||||
for (String key : this.vouchersConfig.getConfigurationSection("vouchers").getKeys(false)) {
|
||||
Voucher voucher = new Voucher(key, this);
|
||||
ConfigurationSection cs = vouchersConfig.getConfigurationSection("vouchers." + key);
|
||||
ConfigurationSection cs = this.vouchersConfig.getConfigurationSection("vouchers." + key);
|
||||
|
||||
Material material;
|
||||
String stringMaterial = cs.getString("material");
|
||||
@ -144,7 +153,9 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
material = Material.PAPER;
|
||||
} else {
|
||||
material = Material.matchMaterial(stringMaterial);
|
||||
if (material == null) material = Material.PAPER;
|
||||
if (material == null) {
|
||||
material = Material.PAPER;
|
||||
}
|
||||
}
|
||||
|
||||
voucher.setPermission(cs.getString("permission", ""))
|
||||
@ -178,7 +189,7 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
.setEffectAmplifier(cs.getInt("effects.amplifier"))
|
||||
.setItemStack(cs.getItemStack("itemstack", null));
|
||||
|
||||
voucherManager.addVoucher(voucher);
|
||||
this.voucherManager.addVoucher(voucher);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -201,14 +212,14 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
private void saveVouchersAsync(Callback callback) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
synchronized (vouchersConfig) {
|
||||
Collection<Voucher> voucherList = voucherManager.getVouchers();
|
||||
synchronized (this.vouchersConfig) {
|
||||
Collection<Voucher> voucherList = this.voucherManager.getVouchers();
|
||||
|
||||
ConfigurationSection cfgSec = vouchersConfig.getConfigurationSection("vouchers");
|
||||
ConfigurationSection cfgSec = this.vouchersConfig.getConfigurationSection("vouchers");
|
||||
if (cfgSec != null) {
|
||||
for (String voucherName : cfgSec.getKeys(false)) {
|
||||
if (voucherList.stream().noneMatch(voucher -> voucher.getKey().equals(voucherName))) {
|
||||
vouchersConfig.set("vouchers." + voucherName, null);
|
||||
this.vouchersConfig.set("vouchers." + voucherName, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -216,39 +227,39 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
for (Voucher voucher : voucherList) {
|
||||
String prefix = "vouchers." + voucher.getKey() + ".";
|
||||
|
||||
vouchersConfig.set(prefix + "permission", voucher.getPermission());
|
||||
vouchersConfig.set(prefix + "material", voucher.getMaterial().name());
|
||||
vouchersConfig.set(prefix + "data", voucher.getData());
|
||||
vouchersConfig.set(prefix + "name", voucher.getName());
|
||||
vouchersConfig.set(prefix + "lore", voucher.getLore());
|
||||
vouchersConfig.set(prefix + "texture", voucher.getTexture());
|
||||
vouchersConfig.set(prefix + "glow", voucher.isGlow());
|
||||
vouchersConfig.set(prefix + "confirm", voucher.isConfirm());
|
||||
vouchersConfig.set(prefix + "unbreakable", voucher.isUnbreakable());
|
||||
vouchersConfig.set(prefix + "hide-attributes", voucher.isHideAttributes());
|
||||
vouchersConfig.set(prefix + "remove-item", voucher.isRemoveItem());
|
||||
vouchersConfig.set(prefix + "heal-player", voucher.isHealPlayer());
|
||||
vouchersConfig.set(prefix + "smite-effect", voucher.isSmiteEffect());
|
||||
vouchersConfig.set(prefix + "coolDown", voucher.getCoolDown());
|
||||
vouchersConfig.set(prefix + "broadcasts", voucher.getBroadcasts());
|
||||
vouchersConfig.set(prefix + "messages", voucher.getMessages());
|
||||
vouchersConfig.set(prefix + "commands", voucher.getCommands());
|
||||
vouchersConfig.set(prefix + "actionbar", voucher.getActionBar());
|
||||
vouchersConfig.set(prefix + "titles.title", voucher.getTitle());
|
||||
vouchersConfig.set(prefix + "titles.subtitle", voucher.getSubTitle());
|
||||
vouchersConfig.set(prefix + "titles.fade-in", voucher.getTitleFadeIn());
|
||||
vouchersConfig.set(prefix + "titles.stay", voucher.getTitleStay());
|
||||
vouchersConfig.set(prefix + "titles.fade-out", voucher.getTitleFadeOut());
|
||||
vouchersConfig.set(prefix + "sounds.sound", voucher.getSound());
|
||||
vouchersConfig.set(prefix + "sounds.pitch", voucher.getSoundPitch());
|
||||
vouchersConfig.set(prefix + "particles.particle", voucher.getParticle());
|
||||
vouchersConfig.set(prefix + "particles.amount", voucher.getParticleAmount());
|
||||
vouchersConfig.set(prefix + "effects.effect", voucher.getEffect());
|
||||
vouchersConfig.set(prefix + "effects.amplifier", voucher.getEffectAmplifier());
|
||||
vouchersConfig.set(prefix + "itemstack", voucher.getItemStack());
|
||||
this.vouchersConfig.set(prefix + "permission", voucher.getPermission());
|
||||
this.vouchersConfig.set(prefix + "material", voucher.getMaterial().name());
|
||||
this.vouchersConfig.set(prefix + "data", voucher.getData());
|
||||
this.vouchersConfig.set(prefix + "name", voucher.getName());
|
||||
this.vouchersConfig.set(prefix + "lore", voucher.getLore());
|
||||
this.vouchersConfig.set(prefix + "texture", voucher.getTexture());
|
||||
this.vouchersConfig.set(prefix + "glow", voucher.isGlow());
|
||||
this.vouchersConfig.set(prefix + "confirm", voucher.isConfirm());
|
||||
this.vouchersConfig.set(prefix + "unbreakable", voucher.isUnbreakable());
|
||||
this.vouchersConfig.set(prefix + "hide-attributes", voucher.isHideAttributes());
|
||||
this.vouchersConfig.set(prefix + "remove-item", voucher.isRemoveItem());
|
||||
this.vouchersConfig.set(prefix + "heal-player", voucher.isHealPlayer());
|
||||
this.vouchersConfig.set(prefix + "smite-effect", voucher.isSmiteEffect());
|
||||
this.vouchersConfig.set(prefix + "coolDown", voucher.getCoolDown());
|
||||
this.vouchersConfig.set(prefix + "broadcasts", voucher.getBroadcasts());
|
||||
this.vouchersConfig.set(prefix + "messages", voucher.getMessages());
|
||||
this.vouchersConfig.set(prefix + "commands", voucher.getCommands());
|
||||
this.vouchersConfig.set(prefix + "actionbar", voucher.getActionBar());
|
||||
this.vouchersConfig.set(prefix + "titles.title", voucher.getTitle());
|
||||
this.vouchersConfig.set(prefix + "titles.subtitle", voucher.getSubTitle());
|
||||
this.vouchersConfig.set(prefix + "titles.fade-in", voucher.getTitleFadeIn());
|
||||
this.vouchersConfig.set(prefix + "titles.stay", voucher.getTitleStay());
|
||||
this.vouchersConfig.set(prefix + "titles.fade-out", voucher.getTitleFadeOut());
|
||||
this.vouchersConfig.set(prefix + "sounds.sound", voucher.getSound());
|
||||
this.vouchersConfig.set(prefix + "sounds.pitch", voucher.getSoundPitch());
|
||||
this.vouchersConfig.set(prefix + "particles.particle", voucher.getParticle());
|
||||
this.vouchersConfig.set(prefix + "particles.amount", voucher.getParticleAmount());
|
||||
this.vouchersConfig.set(prefix + "effects.effect", voucher.getEffect());
|
||||
this.vouchersConfig.set(prefix + "effects.amplifier", voucher.getEffectAmplifier());
|
||||
this.vouchersConfig.set(prefix + "itemstack", voucher.getItemStack());
|
||||
}
|
||||
|
||||
vouchersConfig.saveChanges();
|
||||
this.vouchersConfig.saveChanges();
|
||||
|
||||
callback.accept(null);
|
||||
}
|
||||
@ -260,8 +271,8 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public void onConfigReload() {
|
||||
synchronized (vouchersConfig) {
|
||||
vouchersConfig.load();
|
||||
synchronized (this.vouchersConfig) {
|
||||
this.vouchersConfig.load();
|
||||
}
|
||||
|
||||
loadVouchersFromFile();
|
||||
@ -272,7 +283,7 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public List<Config> getExtraConfig() {
|
||||
return Collections.singletonList(vouchersConfig);
|
||||
return Collections.singletonList(this.vouchersConfig);
|
||||
}
|
||||
|
||||
public Connections getConnections() {
|
||||
@ -288,14 +299,14 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
return this.commandManager;
|
||||
}
|
||||
|
||||
public VoucherManager getVoucherManager() {
|
||||
return voucherManager;
|
||||
return this.voucherManager;
|
||||
}
|
||||
|
||||
public GuiManager getGuiManager() {
|
||||
return guiManager;
|
||||
return this.guiManager;
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.menus.VoucherMenu;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.menus.VoucherMenu;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -12,13 +12,13 @@ public class CommandEditor extends AbstractCommand {
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandEditor(EpicVouchers instance) {
|
||||
super(true, "editor");
|
||||
super(CommandType.PLAYER_ONLY, "EpicVouchers");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
new VoucherMenu(instance).open((Player) sender);
|
||||
new VoucherMenu(this.instance).open((Player) sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -11,17 +11,17 @@ public class CommandEpicVouchers extends AbstractCommand {
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandEpicVouchers(EpicVouchers instance) {
|
||||
super(false, "EpicVouchers");
|
||||
super(CommandType.CONSOLE_OK, "EpicVouchers");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
instance.getLocale().newMessage("&7Version " + instance.getDescription().getVersion()
|
||||
+ " Created with <3 by &5&l&oSongoda").sendPrefixedMessage(sender);
|
||||
this.instance.getLocale().newMessage("&7Version " + this.instance.getDescription().getVersion()
|
||||
+ " Created with <3 by &5&l&oCraftaro").sendPrefixedMessage(sender);
|
||||
|
||||
for (AbstractCommand command : instance.getCommandManager().getAllCommands()) {
|
||||
for (AbstractCommand command : this.instance.getCommandManager().getAllCommands()) {
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -15,29 +15,30 @@ public class CommandForce extends AbstractCommand {
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandForce(EpicVouchers instance) {
|
||||
super(false, "force");
|
||||
super(CommandType.CONSOLE_OK, "force");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 3)
|
||||
if (args.length != 3) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
if (Bukkit.getPlayer(args[0]) == null) {
|
||||
instance.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender);
|
||||
this.instance.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
Voucher voucher = instance.getVoucherManager().getVoucher(args[1]);
|
||||
Voucher voucher = this.instance.getVoucherManager().getVoucher(args[1]);
|
||||
if (voucher == null) {
|
||||
sender.sendMessage("Unknown voucher...");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
voucher.forceRedeem(sender, Collections.singletonList(player), Integer.parseInt(args[2]));
|
||||
instance.getLocale().getMessage("command.force.send")
|
||||
this.instance.getLocale().getMessage("command.force.send")
|
||||
.processPlaceholder("player", player.getName())
|
||||
.processPlaceholder("voucher", voucher.getName(true))
|
||||
.processPlaceholder("amount", args[2].trim())
|
||||
@ -54,7 +55,7 @@ public class CommandForce extends AbstractCommand {
|
||||
result.add(online.getName());
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
for (Voucher voucher : instance.getVoucherManager().getVouchers()) {
|
||||
for (Voucher voucher : this.instance.getVoucherManager().getVouchers()) {
|
||||
result.add(voucher.getKey());
|
||||
}
|
||||
} else if (args.length == 3) {
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -13,23 +13,24 @@ public class CommandForceAll extends AbstractCommand {
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandForceAll(EpicVouchers instance) {
|
||||
super(false, "forceall");
|
||||
super(CommandType.CONSOLE_OK, "forceall");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 2)
|
||||
if (args.length != 2) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
Voucher voucher = instance.getVoucherManager().getVoucher(args[0]);
|
||||
Voucher voucher = this.instance.getVoucherManager().getVoucher(args[0]);
|
||||
if (voucher == null) {
|
||||
sender.sendMessage("Unknown voucher...");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
voucher.forceRedeem(sender, new ArrayList<>(Bukkit.getOnlinePlayers()), Integer.parseInt(args[1]));
|
||||
instance.getLocale().getMessage("command.force.send")
|
||||
this.instance.getLocale().getMessage("command.force.send")
|
||||
.processPlaceholder("player", "everyone")
|
||||
.processPlaceholder("voucher", voucher.getName(true))
|
||||
.processPlaceholder("amount", args[1].trim())
|
||||
@ -42,7 +43,7 @@ public class CommandForceAll extends AbstractCommand {
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (args.length == 1) {
|
||||
for (Voucher voucher : instance.getVoucherManager().getVouchers()) {
|
||||
for (Voucher voucher : this.instance.getVoucherManager().getVouchers()) {
|
||||
result.add(voucher.getKey());
|
||||
}
|
||||
} else if (args.length == 2) {
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -15,22 +15,23 @@ public class CommandGive extends AbstractCommand {
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandGive(EpicVouchers instance) {
|
||||
super(false, "give");
|
||||
super(CommandType.CONSOLE_OK, "give");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 3)
|
||||
if (args.length != 3) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
if (Bukkit.getPlayer(args[0]) == null) {
|
||||
instance.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender);
|
||||
this.instance.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
Voucher voucher = instance.getVoucherManager().getVoucher(args[1]);
|
||||
Voucher voucher = this.instance.getVoucherManager().getVoucher(args[1]);
|
||||
if (voucher == null) {
|
||||
sender.sendMessage("Unknown voucher...");
|
||||
return ReturnType.FAILURE;
|
||||
@ -49,7 +50,7 @@ public class CommandGive extends AbstractCommand {
|
||||
result.add(online.getName());
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
for (Voucher voucher : instance.getVoucherManager().getVouchers()) {
|
||||
for (Voucher voucher : this.instance.getVoucherManager().getVouchers()) {
|
||||
result.add(voucher.getKey());
|
||||
}
|
||||
} else if (args.length == 3) {
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -12,16 +12,17 @@ public class CommandGiveAll extends AbstractCommand {
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandGiveAll(EpicVouchers instance) {
|
||||
super(false, "giveall");
|
||||
super(CommandType.CONSOLE_OK, "giveall");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 2)
|
||||
if (args.length != 2) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
Voucher voucher = instance.getVoucherManager().getVoucher(args[0]);
|
||||
Voucher voucher = this.instance.getVoucherManager().getVoucher(args[0]);
|
||||
if (voucher == null) {
|
||||
sender.sendMessage("Unknown voucher...");
|
||||
return ReturnType.FAILURE;
|
||||
@ -36,7 +37,7 @@ public class CommandGiveAll extends AbstractCommand {
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (args.length == 1) {
|
||||
for (Voucher voucher : instance.getVoucherManager().getVouchers()) {
|
||||
for (Voucher voucher : this.instance.getVoucherManager().getVouchers()) {
|
||||
result.add(voucher.getKey());
|
||||
}
|
||||
} else if (args.length == 2) {
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
@ -12,18 +12,18 @@ public class CommandList extends AbstractCommand {
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandList(EpicVouchers instance) {
|
||||
super(false, "list");
|
||||
super(CommandType.CONSOLE_OK, "list");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
for (Voucher voucher : instance.getVoucherManager().getVouchers()) {
|
||||
for (Voucher voucher : this.instance.getVoucherManager().getVouchers()) {
|
||||
joiner.add(voucher.getKey());
|
||||
}
|
||||
|
||||
instance.getLocale().getMessage("command.list.list")
|
||||
this.instance.getLocale().getMessage("command.list.list")
|
||||
.processPlaceholder("list", joiner.toString())
|
||||
.sendPrefixedMessage(sender);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
@ -10,14 +10,14 @@ public class CommandReload extends AbstractCommand {
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandReload(EpicVouchers instance) {
|
||||
super(false, "reload");
|
||||
super(CommandType.CONSOLE_OK, "reload");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
instance.reloadConfig();
|
||||
instance.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||
this.instance.reloadConfig();
|
||||
this.instance.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicvouchers.events;
|
||||
package com.craftaro.epicvouchers.events;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -7,7 +7,7 @@ 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 static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private final String voucher;
|
||||
@ -24,35 +24,35 @@ public class ForceRedeemEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public String getVoucher() {
|
||||
return voucher;
|
||||
return this.voucher;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicvouchers.events;
|
||||
package com.craftaro.epicvouchers.events;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -8,8 +8,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class VoucherReceiveEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private final String voucher;
|
||||
@ -28,39 +27,39 @@ public class VoucherReceiveEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public String getVoucher() {
|
||||
return voucher;
|
||||
return this.voucher;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicvouchers.events;
|
||||
package com.craftaro.epicvouchers.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@ -7,8 +7,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class VoucherRedeemEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private final String voucher;
|
||||
@ -25,35 +24,35 @@ public class VoucherRedeemEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public String getVoucher() {
|
||||
return voucher;
|
||||
return this.voucher;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public boolean getManual() {
|
||||
return manual;
|
||||
return this.manual;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.epicvouchers.handlers;
|
||||
package com.craftaro.epicvouchers.handlers;
|
||||
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.Connection;
|
||||
@ -19,17 +19,17 @@ public class Connections {
|
||||
}
|
||||
|
||||
public void openMySQL() {
|
||||
if (!instance.getConfig().getBoolean("Database.Activate Mysql Support") || connection == null) {
|
||||
if (!this.instance.getConfig().getBoolean("Database.Activate Mysql Support") || this.connection == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String mysqlIP = instance.getConfig().getString("Database.IP");
|
||||
String mysqlPort = instance.getConfig().getString("Database.PORT");
|
||||
String mysqlDatabase = instance.getConfig().getString("Database.Database Name");
|
||||
String mysqlUsername = instance.getConfig().getString("Database.Username");
|
||||
String mysqlPassword = instance.getConfig().getString("Database.Password");
|
||||
String mysqlIP = this.instance.getConfig().getString("Database.IP");
|
||||
String mysqlPort = this.instance.getConfig().getString("Database.PORT");
|
||||
String mysqlDatabase = this.instance.getConfig().getString("Database.Database Name");
|
||||
String mysqlUsername = this.instance.getConfig().getString("Database.Username");
|
||||
String mysqlPassword = this.instance.getConfig().getString("Database.Password");
|
||||
|
||||
connection = DriverManager.getConnection("jdbc:mysql://" + mysqlIP + ":" + mysqlPort + "/" + mysqlDatabase + "?useSSL=true?autoReconnect=true", mysqlUsername, mysqlPassword);
|
||||
this.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) {
|
||||
System.out.println(TextUtils.formatText("&cFailed to create a connection with MySQL."));
|
||||
@ -38,11 +38,11 @@ public class Connections {
|
||||
}
|
||||
|
||||
public void closeMySQL() {
|
||||
if (!instance.getConfig().getBoolean("Database.Activate Mysql Support") || connection == null) {
|
||||
if (!this.instance.getConfig().getBoolean("Database.Activate Mysql Support") || this.connection == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
connection.close();
|
||||
this.connection.close();
|
||||
System.out.println(TextUtils.formatText("&fSuccessfully closed the MySQL connection."));
|
||||
} catch (Exception error) {
|
||||
System.out.println(TextUtils.formatText("&cFailed to close the MySQL connection."));
|
||||
@ -51,14 +51,14 @@ public class Connections {
|
||||
}
|
||||
|
||||
public void saveRedeem(Player player, String voucher) {
|
||||
if (!instance.getConfig().getBoolean("Database.Activate Mysql Support") || connection == null) {
|
||||
if (!this.instance.getConfig().getBoolean("Database.Activate Mysql Support") || this.connection == null) {
|
||||
return;
|
||||
}
|
||||
Timestamp stamp = new Timestamp(System.currentTimeMillis());
|
||||
Date date = new Date(stamp.getTime());
|
||||
String time = date.toString();
|
||||
try {
|
||||
Statement statement = connection.createStatement();
|
||||
Statement statement = this.connection.createStatement();
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS redeems (id INT NOT NULL AUTO_INCREMENT, player varchar(120) NOT NULL, voucher varchar(120) NOT NULL, timestamp varchar(120) NOT NULL, PRIMARY KEY (ID));");
|
||||
statement.execute("INSERT INTO redeems VALUES (default, '" + player.getName() + "', '" + voucher + "', '" + time + "');");
|
||||
statement.close();
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicvouchers.libraries;
|
||||
package com.craftaro.epicvouchers.libraries;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
@ -63,7 +63,7 @@ public class ItemBuilder {
|
||||
}
|
||||
|
||||
public ItemMeta getMeta() {
|
||||
return meta;
|
||||
return this.meta;
|
||||
}
|
||||
|
||||
public ItemBuilder meta(ItemMeta meta) {
|
||||
@ -75,15 +75,15 @@ public class ItemBuilder {
|
||||
* Name:
|
||||
*/
|
||||
public boolean hasName() {
|
||||
return meta.hasDisplayName();
|
||||
return this.meta.hasDisplayName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return meta.getDisplayName();
|
||||
return this.meta.getDisplayName();
|
||||
}
|
||||
|
||||
public ItemBuilder name(String name) {
|
||||
meta.setDisplayName(name);
|
||||
this.meta.setDisplayName(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -91,11 +91,11 @@ public class ItemBuilder {
|
||||
* Lore:
|
||||
*/
|
||||
public boolean hasLore() {
|
||||
return meta.hasLore();
|
||||
return this.meta.hasLore();
|
||||
}
|
||||
|
||||
public List<String> getLore() {
|
||||
return meta.getLore();
|
||||
return this.meta.getLore();
|
||||
}
|
||||
|
||||
public ItemBuilder lore(String... lore) {
|
||||
@ -103,7 +103,7 @@ public class ItemBuilder {
|
||||
}
|
||||
|
||||
public ItemBuilder lore(List<String> lore) {
|
||||
meta.setLore(lore);
|
||||
this.meta.setLore(lore);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -111,28 +111,28 @@ public class ItemBuilder {
|
||||
* Enchantments:
|
||||
*/
|
||||
public boolean hasEnchants() {
|
||||
return meta.hasEnchants();
|
||||
return this.meta.hasEnchants();
|
||||
}
|
||||
|
||||
public boolean hasEnchant(Enchantment enchantment) {
|
||||
return meta.hasEnchant(enchantment);
|
||||
return this.meta.hasEnchant(enchantment);
|
||||
}
|
||||
|
||||
public boolean hasConflictingEnchant(Enchantment enchantment) {
|
||||
return meta.hasConflictingEnchant(enchantment);
|
||||
return this.meta.hasConflictingEnchant(enchantment);
|
||||
}
|
||||
|
||||
public Map<Enchantment, Integer> getEnchants() {
|
||||
return meta.getEnchants();
|
||||
return this.meta.getEnchants();
|
||||
}
|
||||
|
||||
public ItemBuilder enchant(Enchantment enchantment, int level) {
|
||||
meta.addEnchant(enchantment, level, true);
|
||||
this.meta.addEnchant(enchantment, level, true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder removeEnchant(Enchantment enchantment) {
|
||||
meta.removeEnchant(enchantment);
|
||||
this.meta.removeEnchant(enchantment);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -144,20 +144,20 @@ public class ItemBuilder {
|
||||
* Flags:
|
||||
*/
|
||||
public boolean hasFlag(ItemFlag flag) {
|
||||
return meta.hasItemFlag(flag);
|
||||
return this.meta.hasItemFlag(flag);
|
||||
}
|
||||
|
||||
public Set<ItemFlag> getFlags() {
|
||||
return meta.getItemFlags();
|
||||
return this.meta.getItemFlags();
|
||||
}
|
||||
|
||||
public ItemBuilder addFlags(ItemFlag... flags) {
|
||||
meta.addItemFlags(flags);
|
||||
this.meta.addItemFlags(flags);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder removeFlags(ItemFlag... flags) {
|
||||
meta.removeItemFlags(flags);
|
||||
this.meta.removeItemFlags(flags);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -165,16 +165,15 @@ public class ItemBuilder {
|
||||
* Unbreakability:
|
||||
*/
|
||||
public boolean isUnbreakable() {
|
||||
return meta.isUnbreakable();
|
||||
return this.meta.isUnbreakable();
|
||||
}
|
||||
|
||||
public ItemBuilder unbreakable() {
|
||||
return unbreakable(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemBuilder unbreakable(boolean unbreakable) {
|
||||
meta.setUnbreakable(unbreakable);
|
||||
this.meta.setUnbreakable(unbreakable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -190,36 +189,36 @@ public class ItemBuilder {
|
||||
* Banners:
|
||||
*/
|
||||
public DyeColor getBannerBaseColor() {
|
||||
return ((BannerMeta) meta).getBaseColor();
|
||||
return ((BannerMeta) this.meta).getBaseColor();
|
||||
}
|
||||
|
||||
public List<Pattern> getBannerPatterns() {
|
||||
return ((BannerMeta) meta).getPatterns();
|
||||
return ((BannerMeta) this.meta).getPatterns();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemBuilder bannerBaseColor(DyeColor color) {
|
||||
((BannerMeta) meta).setBaseColor(color);
|
||||
((BannerMeta) this.meta).setBaseColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder bannerPatterns(List<Pattern> patterns) {
|
||||
((BannerMeta) meta).setPatterns(patterns);
|
||||
((BannerMeta) this.meta).setPatterns(patterns);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder bannerPattern(int i, Pattern pattern) {
|
||||
((BannerMeta) meta).setPattern(i, pattern);
|
||||
((BannerMeta) this.meta).setPattern(i, pattern);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addBannerPatterns(Pattern pattern) {
|
||||
((BannerMeta) meta).addPattern(pattern);
|
||||
((BannerMeta) this.meta).addPattern(pattern);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder removeBannerPattern(int i) {
|
||||
((BannerMeta) meta).removePattern(i);
|
||||
((BannerMeta) this.meta).removePattern(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -227,11 +226,11 @@ public class ItemBuilder {
|
||||
* Leather armor:
|
||||
*/
|
||||
public Color getLeatherArmorColor() {
|
||||
return ((LeatherArmorMeta) meta).getColor();
|
||||
return ((LeatherArmorMeta) this.meta).getColor();
|
||||
}
|
||||
|
||||
public ItemBuilder leatherArmorColor(Color color) {
|
||||
((LeatherArmorMeta) meta).setColor(color);
|
||||
((LeatherArmorMeta) this.meta).setColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -239,23 +238,23 @@ public class ItemBuilder {
|
||||
* Skulls:
|
||||
*/
|
||||
public boolean hasSkullOwner() {
|
||||
return ((SkullMeta) meta).hasOwner();
|
||||
return ((SkullMeta) this.meta).hasOwner();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getSkullOwner() {
|
||||
return ((SkullMeta) meta).getOwner();
|
||||
return ((SkullMeta) this.meta).getOwner();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemBuilder skullOwner(String owner) {
|
||||
item.setDurability((short) 3);
|
||||
((SkullMeta) meta).setOwner(owner);
|
||||
this.item.setDurability((short) 3);
|
||||
((SkullMeta) this.meta).setOwner(owner);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder durability(int durability) {
|
||||
item.setDurability((short) durability);
|
||||
this.item.setDurability((short) durability);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -263,19 +262,19 @@ public class ItemBuilder {
|
||||
* Potions:
|
||||
*/
|
||||
public boolean hasPotionEffect(PotionEffectType type) {
|
||||
return ((PotionMeta) meta).hasCustomEffect(type);
|
||||
return ((PotionMeta) this.meta).hasCustomEffect(type);
|
||||
}
|
||||
|
||||
public boolean hasPotionEffects() {
|
||||
return ((PotionMeta) meta).hasCustomEffects();
|
||||
return ((PotionMeta) this.meta).hasCustomEffects();
|
||||
}
|
||||
|
||||
public List<PotionEffect> getPotionEffects() {
|
||||
return ((PotionMeta) meta).getCustomEffects();
|
||||
return ((PotionMeta) this.meta).getCustomEffects();
|
||||
}
|
||||
|
||||
public ItemBuilder addPotionEffect(PotionEffect effect, boolean overwrite) {
|
||||
((PotionMeta) meta).addCustomEffect(effect, overwrite);
|
||||
((PotionMeta) this.meta).addCustomEffect(effect, overwrite);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -283,7 +282,7 @@ public class ItemBuilder {
|
||||
* Build the ItemStack.
|
||||
*/
|
||||
public ItemStack build() {
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
this.item.setItemMeta(this.meta);
|
||||
return this.item;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicvouchers.libraries.inventory;
|
||||
package com.craftaro.epicvouchers.libraries.inventory;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -70,7 +70,6 @@ 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) {
|
||||
@ -84,9 +83,9 @@ public class FastInv implements InventoryHolder {
|
||||
|
||||
runSync(() -> {
|
||||
if (type == InventoryType.CHEST && size > 0) {
|
||||
inventory = Bukkit.createInventory(this, size, title);
|
||||
this.inventory = Bukkit.createInventory(this, size, title);
|
||||
} else {
|
||||
inventory = Bukkit.createInventory(this, type, title);
|
||||
this.inventory = Bukkit.createInventory(this, type, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -107,7 +106,6 @@ 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) {
|
||||
@ -119,12 +117,11 @@ 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) {
|
||||
runSync(() -> {
|
||||
int slot = inventory.firstEmpty();
|
||||
int slot = this.inventory.firstEmpty();
|
||||
if (slot >= 0) {
|
||||
addItem(slot, item, listener);
|
||||
}
|
||||
@ -135,13 +132,12 @@ public class FastInv implements InventoryHolder {
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on a specific slot.
|
||||
*
|
||||
* @param slot The slot of the item.
|
||||
* @param item The item to add.
|
||||
*
|
||||
* @param slot The slot of the item.
|
||||
* @param itemStack The item to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int slot, ItemStack item) {
|
||||
return addItem(slot, item, null);
|
||||
public FastInv addItem(int slot, ItemStack itemStack) {
|
||||
return addItem(slot, itemStack, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,17 +145,16 @@ public class FastInv implements InventoryHolder {
|
||||
*
|
||||
* @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) {
|
||||
runSync(() -> {
|
||||
inventory.setItem(slot, itemStack);
|
||||
this.inventory.setItem(slot, itemStack);
|
||||
|
||||
if (listener != null) {
|
||||
itemListeners.put(slot, listener);
|
||||
this.itemListeners.put(slot, listener);
|
||||
} else {
|
||||
itemListeners.remove(slot);
|
||||
this.itemListeners.remove(slot);
|
||||
}
|
||||
});
|
||||
|
||||
@ -169,29 +164,27 @@ public class FastInv implements InventoryHolder {
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on a range of slots.
|
||||
*
|
||||
* @param slotFrom Starting slot to put the item in.
|
||||
* @param slotTo Ending slot to put the item in.
|
||||
* @param item The item to add.
|
||||
*
|
||||
* @param slotFrom Starting slot to put the item in.
|
||||
* @param slotTo Ending slot to put the item in.
|
||||
* @param itemStack The item to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int slotFrom, int slotTo, ItemStack item) {
|
||||
return addItem(slotFrom, slotTo, item, null);
|
||||
public FastInv addItem(int slotFrom, int slotTo, ItemStack itemStack) {
|
||||
return addItem(slotFrom, slotTo, itemStack, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on a range of slots with a {@link FastInvClickListener} to handle clicks.
|
||||
*
|
||||
* @param slotFrom Starting slot to put the item in.
|
||||
* @param slotTo Ending slot to put the item in.
|
||||
* @param item The item to add.
|
||||
* @param listener The IconClickListener for the item.
|
||||
*
|
||||
* @param slotFrom Starting slot to put the item in.
|
||||
* @param slotTo Ending slot to put the item in.
|
||||
* @param itemStack 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) {
|
||||
public FastInv addItem(int slotFrom, int slotTo, ItemStack itemStack, FastInvClickListener listener) {
|
||||
for (int i = slotFrom; i <= slotTo; i++) {
|
||||
addItem(i, item, listener);
|
||||
addItem(i, itemStack, listener);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -201,7 +194,6 @@ 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) {
|
||||
@ -212,14 +204,13 @@ 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) {
|
||||
int height = inventory.getSize() / 9;
|
||||
int height = this.inventory.getSize() / 9;
|
||||
|
||||
addItem(0, 9, item);
|
||||
addItem(inventory.getSize() - 9, inventory.getSize() - 1, item);
|
||||
addItem(this.inventory.getSize() - 9, this.inventory.getSize() - 1, item);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
addItem(i * 9, item);
|
||||
@ -235,7 +226,6 @@ 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) {
|
||||
@ -247,8 +237,8 @@ public class FastInv implements InventoryHolder {
|
||||
|
||||
public FastInv fill(ItemStack itemStack, FastInvClickListener listener) {
|
||||
runSync(() -> {
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
if (inventory.getItem(i) == null) {
|
||||
for (int i = 0; i < this.inventory.getSize(); i++) {
|
||||
if (this.inventory.getItem(i) == null) {
|
||||
addItem(i, itemStack, listener);
|
||||
}
|
||||
}
|
||||
@ -264,11 +254,10 @@ 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) {
|
||||
closeListeners.add(listener);
|
||||
this.closeListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -276,21 +265,20 @@ 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) {
|
||||
clickListeners.add(listener);
|
||||
this.clickListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FastInv setDefaultCancel(boolean value) {
|
||||
cancelled = value;
|
||||
this.cancelled = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getDefaultCancel() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,7 +286,6 @@ 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) {
|
||||
@ -311,11 +298,10 @@ 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) {
|
||||
tasks.add(Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period));
|
||||
this.tasks.add(Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -325,7 +311,7 @@ public class FastInv implements InventoryHolder {
|
||||
* @param player The player to open the menu.
|
||||
*/
|
||||
public void open(Player player) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(inventory));
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(this.inventory));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -336,7 +322,7 @@ public class FastInv implements InventoryHolder {
|
||||
public void open(Player... players) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
for (Player p : players) {
|
||||
p.openInventory(inventory);
|
||||
p.openInventory(this.inventory);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -345,8 +331,8 @@ public class FastInv implements InventoryHolder {
|
||||
* Cancel all tasks.
|
||||
*/
|
||||
public void cancelTasks() {
|
||||
tasks.forEach(BukkitTask::cancel);
|
||||
tasks.clear();
|
||||
this.tasks.forEach(BukkitTask::cancel);
|
||||
this.tasks.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -388,7 +374,7 @@ public class FastInv implements InventoryHolder {
|
||||
* @return This associated FastInv instance.
|
||||
*/
|
||||
public FastInv getInventory() {
|
||||
return inventory;
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -397,7 +383,7 @@ public class FastInv implements InventoryHolder {
|
||||
* @return the player who clicked.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -406,7 +392,7 @@ public class FastInv implements InventoryHolder {
|
||||
* @return Whether the event was cancelled.
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -485,7 +471,7 @@ public class FastInv implements InventoryHolder {
|
||||
*/
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
private static Listener getListener() {
|
||||
@ -549,7 +535,6 @@ 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) {
|
||||
@ -560,7 +545,7 @@ public class FastInv implements InventoryHolder {
|
||||
public void reOpen(Player player) {
|
||||
player.closeInventory();
|
||||
refresh();
|
||||
player.openInventory(inventory);
|
||||
player.openInventory(this.inventory);
|
||||
}
|
||||
|
||||
public void refresh() {
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicvouchers.libraries.inventory;
|
||||
package com.craftaro.epicvouchers.libraries.inventory;
|
||||
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -72,7 +72,6 @@ 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) {
|
||||
@ -86,9 +85,9 @@ public class IconInv implements InventoryHolder {
|
||||
|
||||
runSync(() -> {
|
||||
if (type == InventoryType.CHEST && size > 0) {
|
||||
inventory = Bukkit.createInventory(this, size, title);
|
||||
this.inventory = Bukkit.createInventory(this, size, title);
|
||||
} else {
|
||||
inventory = Bukkit.createInventory(this, type, title);
|
||||
this.inventory = Bukkit.createInventory(this, type, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -109,12 +108,11 @@ 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.
|
||||
*
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public IconInv addIcon(Icon icon) {
|
||||
runSync(() -> {
|
||||
int slot = inventory.firstEmpty();
|
||||
int slot = this.inventory.firstEmpty();
|
||||
if (slot >= 0) {
|
||||
addIcon(slot, icon);
|
||||
}
|
||||
@ -127,13 +125,12 @@ 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) {
|
||||
runSync(() -> {
|
||||
inventory.setItem(slot, icon.getItemStack());
|
||||
itemListeners.put(slot, icon);
|
||||
this.inventory.setItem(slot, icon.getItemStack());
|
||||
this.itemListeners.put(slot, icon);
|
||||
});
|
||||
|
||||
return this;
|
||||
@ -145,7 +142,6 @@ 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) {
|
||||
@ -159,14 +155,13 @@ 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) {
|
||||
int height = inventory.getSize() / 9;
|
||||
int height = this.inventory.getSize() / 9;
|
||||
|
||||
addIcon(0, 9, icon);
|
||||
addIcon(inventory.getSize() - 9, inventory.getSize() - 1, icon);
|
||||
addIcon(this.inventory.getSize() - 9, this.inventory.getSize() - 1, icon);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
addIcon(i * 9, icon);
|
||||
@ -181,7 +176,6 @@ public class IconInv implements InventoryHolder {
|
||||
*
|
||||
* @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) {
|
||||
@ -193,8 +187,8 @@ public class IconInv implements InventoryHolder {
|
||||
|
||||
public IconInv fill(Icon icon) {
|
||||
runSync(() -> {
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
if (inventory.getItem(i) == null) {
|
||||
for (int i = 0; i < this.inventory.getSize(); i++) {
|
||||
if (this.inventory.getItem(i) == null) {
|
||||
addIcon(i, icon);
|
||||
}
|
||||
}
|
||||
@ -218,11 +212,10 @@ 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) {
|
||||
closeListeners.add(listener);
|
||||
this.closeListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -230,11 +223,10 @@ 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) {
|
||||
clickListeners.add(listener);
|
||||
this.clickListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -243,7 +235,6 @@ 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) {
|
||||
@ -256,11 +247,10 @@ 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) {
|
||||
tasks.add(Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period));
|
||||
this.tasks.add(Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -270,7 +260,7 @@ public class IconInv implements InventoryHolder {
|
||||
* @param player The player to open the menu.
|
||||
*/
|
||||
public void open(Player player) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(inventory));
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(this.inventory));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -281,7 +271,7 @@ public class IconInv implements InventoryHolder {
|
||||
public void open(Player... players) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
for (Player p : players) {
|
||||
p.openInventory(inventory);
|
||||
p.openInventory(this.inventory);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -290,8 +280,8 @@ public class IconInv implements InventoryHolder {
|
||||
* Cancel all tasks.
|
||||
*/
|
||||
public void cancelTasks() {
|
||||
tasks.forEach(BukkitTask::cancel);
|
||||
tasks.clear();
|
||||
this.tasks.forEach(BukkitTask::cancel);
|
||||
this.tasks.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -311,7 +301,6 @@ 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) {
|
||||
@ -327,7 +316,7 @@ public class IconInv implements InventoryHolder {
|
||||
void onClose(IconInvCloseEvent event);
|
||||
}
|
||||
|
||||
public static abstract class IconEvent {
|
||||
public abstract static class IconEvent {
|
||||
private final Player player;
|
||||
private final IconInv inventory;
|
||||
private boolean cancelled;
|
||||
@ -344,7 +333,7 @@ public class IconInv implements InventoryHolder {
|
||||
* @return This associated FastInv instance.
|
||||
*/
|
||||
public IconInv getInventory() {
|
||||
return inventory;
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -353,7 +342,7 @@ public class IconInv implements InventoryHolder {
|
||||
* @return the player who clicked.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -362,7 +351,7 @@ public class IconInv implements InventoryHolder {
|
||||
* @return Whether the event was cancelled.
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -434,11 +423,11 @@ public class IconInv implements InventoryHolder {
|
||||
}
|
||||
|
||||
public boolean getDefaultCancel() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public IconInv setDefaultCancel(boolean value) {
|
||||
cancelled = value;
|
||||
this.cancelled = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -449,7 +438,7 @@ public class IconInv implements InventoryHolder {
|
||||
*/
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
private static Listener getListener() {
|
@ -1,15 +1,16 @@
|
||||
package com.songoda.epicvouchers.libraries.inventory;
|
||||
package com.craftaro.epicvouchers.libraries.inventory;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.menus.ActionMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.SkullUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.menus.ActionMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
@ -41,65 +42,60 @@ public abstract class PlayersMenu extends FastInv {
|
||||
@Override
|
||||
public void refresh() {
|
||||
fill(null);
|
||||
final int startIndex = page * (players.size() - 1);
|
||||
final int startIndex = this.page * (this.players.size() - 1);
|
||||
|
||||
IntStream.rangeClosed(0, SLOTS).forEach(slot -> {
|
||||
IntStream.rangeClosed(0, this.SLOTS).forEach(slot -> {
|
||||
int index = startIndex + slot;
|
||||
|
||||
if (index >= players.size()) {
|
||||
if (index >= this.players.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = players.get(index);
|
||||
Player player = this.players.get(index);
|
||||
|
||||
ItemStack itemStack = CompatibleMaterial.PLAYER_HEAD.getItem();
|
||||
ItemStack itemStack = SkullUtils.getSkull(player.getUniqueId());
|
||||
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setDisplayName(YELLOW + player.getName());
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
|
||||
try {
|
||||
skullMeta.setOwningPlayer(player);
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
|
||||
skullMeta.setDisplayName(YELLOW + player.getName());
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
|
||||
addItem(slot, itemStack, event -> playerConsumer.accept(event.getPlayer(), player));
|
||||
addItem(slot, itemStack, event -> this.playerConsumer.accept(event.getPlayer(), player));
|
||||
});
|
||||
|
||||
if (players.size() / SLOTS > page) {
|
||||
if (this.players.size() / this.SLOTS > this.page) {
|
||||
addItem(26, new ItemBuilder(ARROW)
|
||||
.name(YELLOW + "Next")
|
||||
.lore(GRAY + "Click to go to the next page of players")
|
||||
.build(), event -> {
|
||||
page++;
|
||||
this.page++;
|
||||
refresh();
|
||||
});
|
||||
} else {
|
||||
addItem(26, null);
|
||||
}
|
||||
|
||||
if (page > 0) {
|
||||
if (this.page > 0) {
|
||||
addItem(18, new ItemBuilder(ARROW)
|
||||
.name(YELLOW + "Previous")
|
||||
.lore(GRAY + "Click to go to the previous page of players")
|
||||
.build(), event -> {
|
||||
page--;
|
||||
this.page--;
|
||||
refresh();
|
||||
});
|
||||
} else {
|
||||
addItem(18, new ItemBuilder(BARRIER)
|
||||
.name(YELLOW + "Return")
|
||||
.lore(GRAY + "Return to the action menu")
|
||||
.addGlow().build(), event -> new ActionMenu(instance, voucher).open(event.getPlayer()));
|
||||
.addGlow().build(), event -> new ActionMenu(this.instance, this.voucher).open(event.getPlayer()));
|
||||
}
|
||||
|
||||
if (instance.getConfig().getBoolean("Interface.Fill Interfaces With Glass")) {
|
||||
ItemStack fillItem = CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem();
|
||||
if (this.instance.getConfig().getBoolean("Interface.Fill Interfaces With Glass")) {
|
||||
ItemStack fillItem = XMaterial.GRAY_STAINED_GLASS_PANE.parseItem();
|
||||
|
||||
IntStream.rangeClosed(SLOTS + 1, 26).forEach(slot -> {
|
||||
if (getInventory().getItem(slot) == null)
|
||||
IntStream.rangeClosed(this.SLOTS + 1, 26).forEach(slot -> {
|
||||
if (getInventory().getItem(slot) == null) {
|
||||
addItem(slot, new ItemBuilder(fillItem).name(ChatColor.RESET.toString()).build());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Icon {
|
||||
private final ItemStack itemStack;
|
||||
private final Consumer<IconInv.IconClickEvent> consumer;
|
||||
|
||||
public Icon(ItemStack item) {
|
||||
this(item, event -> {
|
||||
});
|
||||
}
|
||||
|
||||
public Icon(ItemStack item, Consumer<IconInv.IconClickEvent> consumer) {
|
||||
this.itemStack = item;
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public void run(IconInv.IconClickEvent e) {
|
||||
this.consumer.accept(e);
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return this.itemStack;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.utils.Pair;
|
||||
import com.craftaro.core.input.ChatPrompt;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.utils.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.input.ChatPrompt;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -38,12 +38,12 @@ public class StringIcon extends Icon {
|
||||
.lore(GRAY + "Current: " + WHITE + current, GRAY + "Right click to edit", GRAY + "Left click to clear").build(), current, consumer, predicate, noLeft);
|
||||
}
|
||||
|
||||
public StringIcon(EpicVouchers instance, ItemStack itemStack, String current, BiConsumer<Player, String> consumer) {
|
||||
this(instance, itemStack, current, consumer, s -> true, false);
|
||||
public StringIcon(EpicVouchers instance, ItemStack item, String current, BiConsumer<Player, String> consumer) {
|
||||
this(instance, item, current, consumer, s -> true, false);
|
||||
}
|
||||
|
||||
public StringIcon(EpicVouchers instance, ItemStack itemStack, String current, BiConsumer<Player, String> consumer, Predicate<String> predicate, boolean noLeft) {
|
||||
super(itemStack, event -> {
|
||||
public StringIcon(EpicVouchers instance, ItemStack item, String current, BiConsumer<Player, String> consumer, Predicate<String> predicate, boolean noLeft) {
|
||||
super(item, event -> {
|
||||
if (!noLeft && event.getClickType() == ClickType.LEFT) {
|
||||
consumer.accept(event.getPlayer(), "");
|
||||
event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully cleared&7."));
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.StringListMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.StringListMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ToggleableIcon extends Icon {
|
||||
private final Consumer<IconInv.IconClickEvent> consumer;
|
||||
|
||||
public ToggleableIcon(String displayname, Consumer<IconInv.IconClickEvent> consumer, boolean state) {
|
||||
super(new ItemBuilder(Material.PAPER)
|
||||
.name(ChatColor.YELLOW + displayname)
|
||||
.lore(state ? ChatColor.GREEN + "ENABLED" : ChatColor.RED + "DISABLED")
|
||||
.build(), event -> {
|
||||
});
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(IconInv.IconClickEvent e) {
|
||||
this.consumer.accept(e);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicvouchers.listeners;
|
||||
package com.craftaro.epicvouchers.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
@ -0,0 +1,112 @@
|
||||
package com.craftaro.epicvouchers.listeners;
|
||||
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.settings.Settings;
|
||||
import com.craftaro.epicvouchers.utils.CachedSet;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class PlayerInteractListener implements Listener {
|
||||
private final EpicVouchers instance;
|
||||
|
||||
private final CachedSet<ItemStack> itemsThatGotLegacyChecked = new CachedSet<>(3 * 60);
|
||||
|
||||
public PlayerInteractListener(EpicVouchers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void voucherListener(PlayerInteractEvent e) {
|
||||
boolean legacyCheckEnabled = Settings.CHECK_FOR_LEGACY_ITEMS.getBoolean();
|
||||
|
||||
ItemStack item = e.getItem();
|
||||
if (item == null || !isRightClickAction(e.getAction())) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTItem nbtItem = new NBTItem(item);
|
||||
|
||||
boolean itemHasVoucher = nbtItem.hasTag("epicvouchers:voucher");
|
||||
boolean itemHasBeenLegacyChecked = !legacyCheckEnabled || this.itemsThatGotLegacyChecked.contains(item);
|
||||
if (!itemHasVoucher && itemHasBeenLegacyChecked) {
|
||||
return;
|
||||
}
|
||||
|
||||
Voucher voucher;
|
||||
Collection<Voucher> allVouchers = this.instance.getVoucherManager().getVouchers();
|
||||
|
||||
if (itemHasVoucher) {
|
||||
String voucherKey = nbtItem.getString("epicvouchers:voucher");
|
||||
voucher = findVoucherForKey(voucherKey, allVouchers);
|
||||
if (voucher != null) {
|
||||
e.setCancelled(true);
|
||||
voucher.redeemVoucher(e);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Settings.CHECK_FOR_LEGACY_ITEMS.getBoolean()) {
|
||||
return;
|
||||
}
|
||||
|
||||
voucher = findVoucherForLegacyItem(item, allVouchers);
|
||||
if (voucher == null) {
|
||||
this.itemsThatGotLegacyChecked.add(item);
|
||||
return;
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
voucher.redeemVoucher(e);
|
||||
}
|
||||
|
||||
private boolean isRightClickAction(Action action) {
|
||||
return action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK;
|
||||
}
|
||||
|
||||
private Voucher findVoucherForKey(String voucherKey, Collection<Voucher> allVouchers) {
|
||||
for (Voucher voucher : allVouchers) {
|
||||
if (voucherKey.equals(voucher.getKey())) {
|
||||
return voucher;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This is a legacy method that is only used for backwards compatibility
|
||||
* with vouchers that were created before the voucher key was stored in NBT.
|
||||
* Some checks in here don't even look like they make sense or look redundant... Hard to touch this.
|
||||
*/
|
||||
@Deprecated
|
||||
private Voucher findVoucherForLegacyItem(ItemStack item, Collection<Voucher> allVouchers) {
|
||||
for (Voucher voucher : allVouchers) {
|
||||
ItemStack voucherItem = voucher.toItemStack();
|
||||
|
||||
if (voucherItem != null && !voucherItem.isSimilar(item)) {
|
||||
continue;
|
||||
}
|
||||
if (item.getType() != voucher.getMaterial() || item.getDurability() != voucher.getData()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// material matches - verify the name + lore
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null && meta.hasDisplayName() && ChatColor.stripColor(meta.getDisplayName()).equals(ChatColor.stripColor(voucher.getName(true))) && (!meta.hasLore() || meta.getLore().equals(voucher.getLore(true)))) {
|
||||
return voucher;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
package com.songoda.epicvouchers.menus;
|
||||
package com.craftaro.epicvouchers.menus;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.songoda.epicvouchers.menus.sub.action.ForceMenu;
|
||||
import com.songoda.epicvouchers.menus.sub.action.GiveMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.craftaro.epicvouchers.menus.sub.action.ForceMenu;
|
||||
import com.craftaro.epicvouchers.menus.sub.action.GiveMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -61,7 +61,7 @@ public class ActionMenu extends FastInv {
|
||||
.addGlow().build(), event -> new VoucherMenu(instance).open(event.getPlayer()));
|
||||
|
||||
if (instance.getConfig().getBoolean("Interface.Fill Interfaces With Glass")) {
|
||||
ItemStack fillItem = CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem();
|
||||
ItemStack fillItem = XMaterial.GRAY_STAINED_GLASS_PANE.parseItem();
|
||||
|
||||
fill(new ItemBuilder(fillItem).name(ChatColor.RESET.toString()).build());
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epicvouchers.menus;
|
||||
package com.craftaro.epicvouchers.menus;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.FastInv;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -34,7 +34,7 @@ public class ConfirmMenu extends FastInv {
|
||||
});
|
||||
|
||||
if (instance.getConfig().getBoolean("Interface.Fill Interfaces With Glass")) {
|
||||
ItemStack fillItem = CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem();
|
||||
ItemStack fillItem = XMaterial.GRAY_STAINED_GLASS_PANE.parseItem();
|
||||
|
||||
fill(new ItemBuilder(fillItem).name(ChatColor.RESET.toString()).build());
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package com.songoda.epicvouchers.menus;
|
||||
package com.craftaro.epicvouchers.menus;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.SetItemMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.SetItemMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import static org.bukkit.ChatColor.GRAY;
|
||||
@ -43,6 +43,6 @@ public class OptionMenu extends FastInv {
|
||||
.lore(TextUtils.formatText("&eSet the options of your voucher."))
|
||||
.build(), event -> new VoucherEditorMenu(instance, voucher).open(event.getPlayer()));
|
||||
|
||||
fill(new ItemBuilder(CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem()).name(ChatColor.RESET.toString()).build());
|
||||
fill(new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseMaterial()).name(ChatColor.RESET.toString()).build());
|
||||
}
|
||||
}
|
@ -1,19 +1,19 @@
|
||||
package com.songoda.epicvouchers.menus;
|
||||
package com.craftaro.epicvouchers.menus;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringListIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.ToggleableIcon;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.EffectsMenu;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.ParticlesMenu;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.SoundsMenu;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.TitlesMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.ItemUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringListIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.ToggleableIcon;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.EffectsMenu;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.ParticlesMenu;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.SoundsMenu;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.TitlesMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -89,7 +89,7 @@ public class VoucherEditorMenu extends IconInv {
|
||||
reopen(player);
|
||||
}));
|
||||
|
||||
addIcon(13, new StringIcon(instance, new ItemBuilder(voucher.getTexture() == null ? CompatibleMaterial.PLAYER_HEAD.getItem() : ItemUtils.getCustomHead(voucher.getTexture()))
|
||||
addIcon(13, new StringIcon(instance, new ItemBuilder(voucher.getTexture() == null ? XMaterial.PLAYER_HEAD.parseItem() : ItemUtils.getCustomHead(voucher.getTexture()))
|
||||
.name(YELLOW + "Skull Texture")
|
||||
.lore(GRAY + "Right click to edit", GRAY + "Left click to clear").build(), voucher.getTexture(), (player, editString) -> {
|
||||
voucher.setTexture(editString);
|
||||
@ -131,6 +131,6 @@ public class VoucherEditorMenu extends IconInv {
|
||||
}
|
||||
|
||||
private void reopen(Player player) {
|
||||
new VoucherEditorMenu(instance, voucher).open(player);
|
||||
new VoucherEditorMenu(this.instance, this.voucher).open(player);
|
||||
}
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
package com.songoda.epicvouchers.menus;
|
||||
package com.craftaro.epicvouchers.menus;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.gui.AnvilGui;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -34,7 +34,7 @@ public class VoucherMenu extends IconInv {
|
||||
.lore(TextUtils.formatText("&eCreate a new voucher with set id.")).build(), event -> {
|
||||
AnvilGui gui = new AnvilGui(event.getPlayer());
|
||||
gui.setTitle("Insert id");
|
||||
gui.setAction(aevent -> {
|
||||
gui.setAction(aEvent -> {
|
||||
final String msg = gui.getInputText().trim();
|
||||
if (instance.getVoucherManager().getVoucher(msg) != null) {
|
||||
event.getPlayer().sendMessage(TextUtils.formatText("&cAlready a voucher registered with the id: " + msg));
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epicvouchers.menus.sub.action;
|
||||
package com.craftaro.epicvouchers.menus.sub.action;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.inventory.PlayersMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.PlayersMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.epicvouchers.menus.sub.action;
|
||||
package com.craftaro.epicvouchers.menus.sub.action;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.inventory.PlayersMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.PlayersMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
@ -1,12 +1,12 @@
|
||||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.songoda.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.craftaro.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import static org.bukkit.ChatColor.GRAY;
|
@ -1,12 +1,12 @@
|
||||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.songoda.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.craftaro.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import static org.bukkit.ChatColor.GRAY;
|
@ -1,11 +1,11 @@
|
||||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.songoda.epicvouchers.menus.OptionMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.craftaro.epicvouchers.menus.OptionMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@ -20,7 +20,7 @@ public class SetItemMenu extends FastInv {
|
||||
|
||||
setDefaultCancel(false);
|
||||
|
||||
fill(new ItemBuilder(CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem())
|
||||
fill(new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseItem())
|
||||
.name(ChatColor.RESET.toString()).build(), event -> event.setCancelled(true));
|
||||
|
||||
addItem(13, null);
|
@ -1,13 +1,13 @@
|
||||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.craftaro.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import com.google.common.base.Enums;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.songoda.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
@ -32,6 +32,5 @@ public class SoundsMenu extends IconInv {
|
||||
.name(YELLOW + "Return")
|
||||
.lore(GRAY + "Return to the editor")
|
||||
.build(), event -> new VoucherEditorMenu(instance, voucher).open(event.getPlayer()));
|
||||
|
||||
}
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.ListEntryIcon;
|
||||
import com.songoda.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.input.ChatPrompt;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.ListEntryIcon;
|
||||
import com.craftaro.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.songoda.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.craftaro.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import static org.bukkit.ChatColor.GRAY;
|
@ -1,18 +1,19 @@
|
||||
package com.songoda.epicvouchers.settings;
|
||||
package com.craftaro.epicvouchers.settings;
|
||||
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.configuration.ConfigSetting;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.craftaro.core.configuration.ConfigSetting;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* Created by songo on 6/4/2017.
|
||||
*/
|
||||
public class Settings implements Listener {
|
||||
static final Config config = EpicVouchers.getInstance().getCoreConfig();
|
||||
static final Config config = EpicVouchers.getPlugin(EpicVouchers.class).getCoreConfig();
|
||||
|
||||
public static final ConfigSetting FILL_GLASS = new ConfigSetting(config, "Interface.Fill Interfaces With Glass", true);
|
||||
public static final ConfigSetting COOLDOWN_DELAY = new ConfigSetting(config, "Main.Cooldown Delay", 10);
|
||||
public static final ConfigSetting CHECK_FOR_LEGACY_ITEMS = new ConfigSetting(config, "Main.Check For Legacy Items", false,
|
||||
"When you have a really old installation of EpicVouchers, some items in chests etc. might still be created with the old system.",
|
||||
"This enables checking/detection for those items.",
|
||||
"2 warnings: Enabling this comes with a performance impact with many vouchers configured + This check will be removed in the future");
|
||||
|
||||
public static final ConfigSetting DATABASE_SUPPORT = new ConfigSetting(config, "Database.Activate Mysql Support", false);
|
||||
public static final ConfigSetting DATABASE_IP = new ConfigSetting(config, "Database.IP", "127.0.0.1");
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.epicvouchers.utils;
|
||||
package com.craftaro.epicvouchers.utils;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class CachedSet<K> {
|
||||
private final Map<K, Long> cache = new WeakHashMap<>();
|
||||
private final Map<K, Long> cache = new WeakHashMap<>(0);
|
||||
private final int ttl;
|
||||
|
||||
private long lastClear = System.currentTimeMillis();
|
||||
@ -25,16 +25,16 @@ public class CachedSet<K> {
|
||||
clearStale();
|
||||
}
|
||||
|
||||
return this.cache.computeIfPresent(obj, (k, aLong) -> System.currentTimeMillis()) != null;
|
||||
return this.cache.computeIfPresent(obj, (key, aLong) -> System.currentTimeMillis()) != null;
|
||||
}
|
||||
|
||||
public void clearStale() {
|
||||
this.cache.entrySet().removeIf(entry -> System.currentTimeMillis() - entry.getValue() >= ttl);
|
||||
this.cache.entrySet().removeIf(entry -> System.currentTimeMillis() - entry.getValue() >= this.ttl);
|
||||
|
||||
this.lastClear = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private boolean shouldClear() {
|
||||
return !this.cache.isEmpty() && System.currentTimeMillis() - lastClear > ttl;
|
||||
return !this.cache.isEmpty() && System.currentTimeMillis() - this.lastClear > this.ttl;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicvouchers.utils;
|
||||
package com.craftaro.epicvouchers.utils;
|
||||
|
||||
// TODO: Copied from EpicAnchors - Move to SongodaCore (maybe rename too?)
|
||||
public interface Callback {
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicvouchers.utils;
|
||||
package com.craftaro.epicvouchers.utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
@ -19,7 +19,9 @@ public class Pair<K, V> implements Serializable {
|
||||
*
|
||||
* @return key for this pair
|
||||
*/
|
||||
public String getKey() { return key; }
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Value of this this <code>Pair</code>.
|
||||
@ -31,7 +33,9 @@ public class Pair<K, V> implements Serializable {
|
||||
*
|
||||
* @return value for this pair
|
||||
*/
|
||||
public String getValue() { return value; }
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new pair
|
||||
@ -54,7 +58,7 @@ public class Pair<K, V> implements Serializable {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return key + "=" + value;
|
||||
return this.key + "=" + this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +76,7 @@ public class Pair<K, V> implements Serializable {
|
||||
// these two parameters:
|
||||
// name: a value: aa
|
||||
// name: aa value: a
|
||||
return key.hashCode() * 13 + (value == null ? 0 : value.hashCode());
|
||||
return this.key.hashCode() * 13 + (this.value == null ? 0 : this.value.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,17 +92,19 @@ public class Pair<K, V> implements Serializable {
|
||||
*
|
||||
* @param o the <code>Object</code> to test for
|
||||
* equality with this <code>Pair</code>
|
||||
*
|
||||
* @return <code>true</code> if the given <code>Object</code> is
|
||||
* equal to this <code>Pair</code> else <code>false</code>
|
||||
* equal to this <code>Pair</code> else <code>false</code>
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Pair<?, ?> pair = (Pair<?, ?>) o;
|
||||
return Objects.equals(key, pair.key) && Objects.equals(value, pair.value);
|
||||
return Objects.equals(this.key, pair.key) && Objects.equals(this.value, pair.value);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicvouchers.utils;
|
||||
package com.craftaro.epicvouchers.utils;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@ -8,10 +8,10 @@ public class ThreadSync {
|
||||
private final AtomicReference<Boolean> waiting = new AtomicReference<>(true);
|
||||
|
||||
public void waitForRelease() {
|
||||
synchronized (syncObj) {
|
||||
while (waiting.get()) {
|
||||
synchronized (this.syncObj) {
|
||||
while (this.waiting.get()) {
|
||||
try {
|
||||
syncObj.wait();
|
||||
this.syncObj.wait();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
@ -19,13 +19,13 @@ public class ThreadSync {
|
||||
}
|
||||
|
||||
public void release() {
|
||||
synchronized (syncObj) {
|
||||
waiting.set(false);
|
||||
syncObj.notifyAll();
|
||||
synchronized (this.syncObj) {
|
||||
this.waiting.set(false);
|
||||
this.syncObj.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
waiting.set(true);
|
||||
this.waiting.set(true);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicvouchers.voucher;
|
||||
package com.craftaro.epicvouchers.voucher;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -21,14 +21,14 @@ public class CoolDownManager {
|
||||
}
|
||||
|
||||
if (voucher.getCoolDown() != 0) {
|
||||
entries.put(uuid, System.currentTimeMillis() + voucher.getCoolDown() * 1000L);
|
||||
this.entries.put(uuid, System.currentTimeMillis() + voucher.getCoolDown() * 1000L);
|
||||
} else {
|
||||
entries.put(uuid, System.currentTimeMillis() + instance.getConfig().getInt("Main.Cooldown Delay") * 1000L);
|
||||
this.entries.put(uuid, System.currentTimeMillis() + this.instance.getConfig().getInt("Main.Cooldown Delay") * 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOnCoolDown(UUID uuid) {
|
||||
Long time = entries.get(uuid);
|
||||
Long time = this.entries.get(uuid);
|
||||
|
||||
if (time == null) {
|
||||
return false;
|
||||
@ -38,12 +38,12 @@ public class CoolDownManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
entries.remove(uuid);
|
||||
this.entries.remove(uuid);
|
||||
return false;
|
||||
}
|
||||
|
||||
public long getTime(UUID uuid) {
|
||||
Long time = entries.get(uuid);
|
||||
Long time = this.entries.get(uuid);
|
||||
|
||||
if (time == null) {
|
||||
return 0L;
|
@ -1,14 +1,14 @@
|
||||
package com.songoda.epicvouchers.voucher;
|
||||
package com.craftaro.epicvouchers.voucher;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.events.ForceRedeemEvent;
|
||||
import com.songoda.epicvouchers.events.VoucherReceiveEvent;
|
||||
import com.songoda.epicvouchers.menus.ConfirmMenu;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.utils.ItemUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.events.ForceRedeemEvent;
|
||||
import com.craftaro.epicvouchers.events.VoucherReceiveEvent;
|
||||
import com.craftaro.epicvouchers.menus.ConfirmMenu;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -21,9 +21,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.bukkit.Material.PAPER;
|
||||
|
||||
@ -81,32 +81,32 @@ public class Voucher {
|
||||
}
|
||||
|
||||
public ItemStack toItemStack(int amount) {
|
||||
ItemStack item = itemStack == null ? new ItemStack(material, amount, data) : itemStack;
|
||||
ItemStack item = this.itemStack == null ? new ItemStack(this.material, amount, this.data) : this.itemStack;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
if (meta == null) {
|
||||
meta = Bukkit.getItemFactory().getItemMeta(material);
|
||||
meta = Bukkit.getItemFactory().getItemMeta(this.material);
|
||||
}
|
||||
|
||||
if (!name.isEmpty()) {
|
||||
meta.setDisplayName(TextUtils.formatText(name));
|
||||
if (!this.name.isEmpty()) {
|
||||
meta.setDisplayName(TextUtils.formatText(this.name));
|
||||
}
|
||||
|
||||
if (lore != null) {
|
||||
if (this.lore != null) {
|
||||
meta.setLore(getLore(true));
|
||||
}
|
||||
|
||||
if (glow) {
|
||||
if (this.glow) {
|
||||
meta.addEnchant(Enchantment.DURABILITY, 1, false);
|
||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
}
|
||||
|
||||
if (hideAttributes) {
|
||||
if (this.hideAttributes) {
|
||||
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||
}
|
||||
|
||||
if (unbreakable) {
|
||||
if (this.unbreakable) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
|
||||
meta.setUnbreakable(true);
|
||||
item.setItemMeta(meta);
|
||||
@ -119,52 +119,76 @@ public class Voucher {
|
||||
}
|
||||
}
|
||||
|
||||
if (texture != null && !texture.isEmpty() && CompatibleMaterial.PLAYER_HEAD.getMaterial() == material) {
|
||||
item = ItemUtils.getCustomHead(texture);
|
||||
if (this.texture != null && !this.texture.isEmpty() && XMaterial.PLAYER_HEAD.parseMaterial() == this.material) {
|
||||
item = ItemUtils.getCustomHead(this.texture);
|
||||
}
|
||||
|
||||
NBTItem nbtItem = new NBTItem(item);
|
||||
nbtItem.setString("epicvouchers:voucher", key);
|
||||
nbtItem.setString("epicvouchers:voucher", this.key);
|
||||
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
|
||||
public String getName(boolean applyFormatting) {
|
||||
return applyFormatting ? TextUtils.formatText(name) : name;
|
||||
return applyFormatting ? TextUtils.formatText(this.name) : this.name;
|
||||
}
|
||||
|
||||
public List<String> getLore(boolean applyFormatting) {
|
||||
return applyFormatting ? lore.stream().map(TextUtils::formatText).collect(Collectors.toList()) : lore;
|
||||
if (!applyFormatting) {
|
||||
return Collections.unmodifiableList(this.lore);
|
||||
}
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String line : this.lore) {
|
||||
lore.add(TextUtils.formatText(line));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
public List<String> getBroadcasts(boolean applyFormatting) {
|
||||
return applyFormatting ? broadcasts.stream().map(TextUtils::formatText).collect(Collectors.toList()) : broadcasts;
|
||||
if (!applyFormatting) {
|
||||
return this.broadcasts;
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String broadcast : this.broadcasts) {
|
||||
result.add(TextUtils.formatText(broadcast));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> getMessages(boolean applyFormatting) {
|
||||
return applyFormatting ? messages.stream().map(TextUtils::formatText).collect(Collectors.toList()) : messages;
|
||||
if (!applyFormatting) {
|
||||
return this.messages;
|
||||
}
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
for (String message : this.messages) {
|
||||
list.add(TextUtils.formatText(message));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void saveSetting(String key, List<String> list) {
|
||||
switch (key) {
|
||||
case "Commands":
|
||||
commands = list;
|
||||
this.commands = list;
|
||||
break;
|
||||
case "Broadcasts":
|
||||
broadcasts = list;
|
||||
this.broadcasts = list;
|
||||
break;
|
||||
case "Messages":
|
||||
messages = list;
|
||||
this.messages = list;
|
||||
break;
|
||||
case "Lore":
|
||||
lore = list;
|
||||
this.lore = list;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return key;
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public void giveAll(CommandSender sender, int amount) {
|
||||
@ -172,13 +196,13 @@ public class Voucher {
|
||||
}
|
||||
|
||||
public void give(CommandSender sender, List<Player> players, int amount) {
|
||||
String giveMessage = instance.getLocale().getMessage("command.give.send")
|
||||
String giveMessage = this.instance.getLocale().getMessage("command.give.send")
|
||||
.processPlaceholder("player", players.size() == 1 ? players.get(0).getName() : "everyone")
|
||||
.processPlaceholder("voucher", getName(true))
|
||||
.processPlaceholder("amount", String.valueOf(amount)).getPrefixedMessage();
|
||||
|
||||
for (Player player : players) {
|
||||
String receiveMessage = instance.getLocale().getMessage("command.give.receive")
|
||||
String receiveMessage = this.instance.getLocale().getMessage("command.give.receive")
|
||||
.processPlaceholder("voucher", getName(true))
|
||||
.processPlaceholder("player", player.getName())
|
||||
.processPlaceholder("amount", String.valueOf(amount)).getPrefixedMessage();
|
||||
@ -187,7 +211,7 @@ public class Voucher {
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
instance.getLocale().getMessage("command.give.cancelled").sendPrefixedMessage(sender);
|
||||
this.instance.getLocale().getMessage("command.give.cancelled").sendPrefixedMessage(sender);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -208,7 +232,7 @@ public class Voucher {
|
||||
}
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
instance.getVoucherExecutor().redeemVoucher(player, this, player.getItemInHand(), false, null);
|
||||
this.instance.getVoucherExecutor().redeemVoucher(player, this, player.getItemInHand(), false, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -217,45 +241,46 @@ public class Voucher {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// does the player have permission to redeem this voucher?
|
||||
if (!permission.isEmpty() && !player.hasPermission(permission)) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.general.nopermission").getPrefixedMessage());
|
||||
if (!this.permission.isEmpty() && !player.hasPermission(this.permission)) {
|
||||
player.sendMessage(this.instance.getLocale().getMessage("event.general.nopermission").getPrefixedMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
|
||||
if (instance.getCoolDowns().isOnCoolDown(uuid)) {
|
||||
instance.getLocale().getMessage("event.general.cooldown")
|
||||
.processPlaceholder("time", instance.getCoolDowns().getTime(uuid))
|
||||
if (this.instance.getCoolDowns().isOnCoolDown(uuid)) {
|
||||
this.instance.getLocale().getMessage("event.general.cooldown")
|
||||
.processPlaceholder("time", this.instance.getCoolDowns().getTime(uuid))
|
||||
.processPlaceholder("voucher", getName(true))
|
||||
.sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm) {
|
||||
new ConfirmMenu(instance,
|
||||
() -> instance.getVoucherExecutor().redeemVoucher(player, this, event.getItem(), true, event),
|
||||
() -> { })
|
||||
if (this.confirm) {
|
||||
new ConfirmMenu(this.instance,
|
||||
() -> this.instance.getVoucherExecutor().redeemVoucher(player, this, event.getItem(), true, event),
|
||||
() -> {
|
||||
})
|
||||
.open(player);
|
||||
} else {
|
||||
instance.getVoucherExecutor().redeemVoucher(player, this, event.getItem(), true, event);
|
||||
this.instance.getVoucherExecutor().redeemVoucher(player, this, event.getItem(), true, event);
|
||||
}
|
||||
}
|
||||
|
||||
public String getTexture() {
|
||||
return texture;
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
public String getActionBar() {
|
||||
return TextUtils.formatText(actionBar);
|
||||
return TextUtils.formatText(this.actionBar);
|
||||
}
|
||||
|
||||
public String getSubTitle() {
|
||||
return TextUtils.formatText(subTitle);
|
||||
return TextUtils.formatText(this.subTitle);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return TextUtils.formatText(title);
|
||||
return TextUtils.formatText(this.title);
|
||||
}
|
||||
|
||||
public String getKey() {
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.epicvouchers.voucher;
|
||||
package com.craftaro.epicvouchers.voucher;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.events.VoucherRedeemEvent;
|
||||
import com.songoda.epicvouchers.listeners.PlayerCommandListener;
|
||||
import com.craftaro.core.compatibility.CompatibleSound;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.events.VoucherRedeemEvent;
|
||||
import com.craftaro.epicvouchers.listeners.PlayerCommandListener;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
@ -51,7 +51,7 @@ public class VoucherExecutor {
|
||||
|
||||
if (!duplication) {
|
||||
if (manual) {
|
||||
instance.getCoolDowns().addCoolDown(player.getUniqueId(), voucher);
|
||||
this.instance.getCoolDowns().addCoolDown(player.getUniqueId(), voucher);
|
||||
if (voucher.isRemoveItem()) {
|
||||
if (item.getAmount() <= 1) {
|
||||
item = null;
|
||||
@ -116,17 +116,14 @@ public class VoucherExecutor {
|
||||
String delayCommand = StringUtils.substringBetween(command, "[", "]");
|
||||
int delay = Integer.parseInt(delayCommand.split("-", 2)[1]);
|
||||
final String finalCommand = command.replace("[" + delayCommand + "]", "");
|
||||
final ItemStack heldItem = item;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
runCommand(finalCommand, player);
|
||||
}, 20 * delay);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this.instance, () -> runCommand(finalCommand, player), 20L * delay);
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
}
|
||||
if (voucher.getActionBar() != null && !voucher.getActionBar().isEmpty()) {
|
||||
String actionbar = voucher.getActionBar().replaceAll("%player%", name).replaceAll("%voucher%", voucher.getName(true));
|
||||
instance.getLocale().newMessage(actionbar).sendActionBar(player);
|
||||
this.instance.getLocale().newMessage(actionbar).sendActionBar(player);
|
||||
}
|
||||
|
||||
if (voucher.getTitle() != null && !voucher.getTitle().isEmpty()) {
|
||||
@ -166,14 +163,14 @@ public class VoucherExecutor {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(effect), duration, amplifier));
|
||||
}
|
||||
|
||||
instance.getLogger().log(Level.INFO, player.getName() + " has successfully redeemed the voucher " + voucher.getKey() + ".");
|
||||
instance.getConnections().saveRedeem(player, voucher.getName(true));
|
||||
this.instance.getLogger().log(Level.INFO, player.getName() + " has successfully redeemed the voucher " + voucher.getKey() + ".");
|
||||
this.instance.getConnections().saveRedeem(player, voucher.getName(true));
|
||||
} else {
|
||||
instance.getLogger().log(Level.WARNING, player.getName() + " has failed to duplicate the voucher " + voucher.getKey() + ".");
|
||||
this.instance.getLogger().log(Level.WARNING, player.getName() + " has failed to duplicate the voucher " + voucher.getKey() + ".");
|
||||
}
|
||||
} catch (Exception error) {
|
||||
instance.getLogger().log(Level.SEVERE, "Failed to redeem the voucher " + voucher.getKey() + " for the player " + player.getName() + ".");
|
||||
instance.getLogger().log(Level.SEVERE, error.getMessage());
|
||||
this.instance.getLogger().log(Level.SEVERE, "Failed to redeem the voucher " + voucher.getKey() + " for the player " + player.getName() + ".");
|
||||
this.instance.getLogger().log(Level.SEVERE, error.getMessage());
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.epicvouchers.voucher;
|
||||
package com.craftaro.epicvouchers.voucher;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -8,22 +8,22 @@ public class VoucherManager {
|
||||
private final Map<String, Voucher> registeredVouchers = new HashMap<>();
|
||||
|
||||
public Voucher addVoucher(Voucher voucher) {
|
||||
return registeredVouchers.put(voucher.getKey(), voucher);
|
||||
return this.registeredVouchers.put(voucher.getKey(), voucher);
|
||||
}
|
||||
|
||||
public Voucher removeVoucher(Voucher voucher) {
|
||||
return registeredVouchers.remove(voucher);
|
||||
return this.registeredVouchers.remove(voucher);
|
||||
}
|
||||
|
||||
public Voucher getVoucher(String key) {
|
||||
return registeredVouchers.get(key);
|
||||
return this.registeredVouchers.get(key);
|
||||
}
|
||||
|
||||
public Collection<Voucher> getVouchers() {
|
||||
return registeredVouchers.values();
|
||||
return this.registeredVouchers.values();
|
||||
}
|
||||
|
||||
public void clearVouchers() {
|
||||
registeredVouchers.clear();
|
||||
this.registeredVouchers.clear();
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv.IconClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Icon {
|
||||
private final ItemStack itemStack;
|
||||
private final Consumer<IconClickEvent> consumer;
|
||||
|
||||
public Icon(ItemStack itemStack) {
|
||||
this(itemStack, event -> { });
|
||||
}
|
||||
|
||||
public Icon(ItemStack item, Consumer<IconClickEvent> consumer) {
|
||||
this.itemStack = item;
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public void run(IconClickEvent e) { consumer.accept(e); }
|
||||
|
||||
public ItemStack getItemStack() { return itemStack; }
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv.IconClickEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ToggleableIcon extends Icon {
|
||||
private Consumer<IconClickEvent> consumer;
|
||||
|
||||
public ToggleableIcon(String displayname, Consumer<IconClickEvent> consumer, boolean state) {
|
||||
super(new ItemBuilder(Material.PAPER)
|
||||
.name(ChatColor.YELLOW + displayname)
|
||||
.lore(state ? ChatColor.GREEN + "ENABLED" : ChatColor.RED + "DISABLED")
|
||||
.build(), event -> { });
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(IconClickEvent event) {
|
||||
consumer.accept(event);
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package com.songoda.epicvouchers.listeners;
|
||||
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.utils.CachedSet;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class PlayerInteractListener implements Listener {
|
||||
private final EpicVouchers instance;
|
||||
|
||||
private final CachedSet<ItemStack> checkedLegacyVouchers = new CachedSet<>(3 * 60);
|
||||
|
||||
public PlayerInteractListener(EpicVouchers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void voucherListener(PlayerInteractEvent e) {
|
||||
ItemStack item = e.getItem();
|
||||
|
||||
if (item != null && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
|
||||
NBTItem itemNbt = new NBTItem(item);
|
||||
|
||||
boolean itemHasVoucher = itemNbt.hasKey("epicvouchers:voucher");
|
||||
String itemVoucherValue = itemNbt.getString("epicvouchers:voucher");
|
||||
|
||||
boolean legacyChecked = checkedLegacyVouchers.contains(item);
|
||||
|
||||
if (itemHasVoucher || !legacyChecked) {
|
||||
boolean shouldBeLegacyCached = !itemHasVoucher;
|
||||
|
||||
for (Voucher voucher : instance.getVoucherManager().getVouchers()) {
|
||||
// Check voucher NBT.
|
||||
if (itemHasVoucher && itemVoucherValue.equals(voucher.getKey())) {
|
||||
e.setCancelled(true);
|
||||
voucher.redeemVoucher(e);
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: eventually make the legacy check configurable as a lot of players (and vouchers) quickly cause lag
|
||||
// Legacy crap.
|
||||
// does the item they're holding match this voucher?
|
||||
ItemStack voucherItem = voucher.toItemStack();
|
||||
|
||||
if ((voucherItem == null || voucherItem.isSimilar(item)) &&
|
||||
item.getType() == voucher.getMaterial() &&
|
||||
item.getDurability() == voucher.getData()) {
|
||||
// material matches - verify the name + lore
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
if (meta != null && meta.hasDisplayName()
|
||||
&& ChatColor.stripColor(meta.getDisplayName()).equals(ChatColor.stripColor(voucher.getName(true)))
|
||||
&& (!meta.hasLore() || meta.getLore().equals(voucher.getLore(true)))) {
|
||||
e.setCancelled(true);
|
||||
voucher.redeemVoucher(e);
|
||||
|
||||
shouldBeLegacyCached = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldBeLegacyCached) {
|
||||
this.checkedLegacyVouchers.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,14 +3,12 @@ description: ${project.description}
|
||||
version: ${project.version}
|
||||
api-version: 1.13
|
||||
|
||||
main: com.songoda.epicvouchers.EpicVouchers
|
||||
main: com.craftaro.epicvouchers.EpicVouchers
|
||||
|
||||
author: Songoda
|
||||
author: Craftaro
|
||||
website: ${project.url}
|
||||
|
||||
commands:
|
||||
epicvouchers:
|
||||
description: View information on this plugin.
|
||||
EpicVouchers:
|
||||
default: true
|
||||
aliases: [ev]
|
||||
usage: /ev
|
||||
aliases: [ ev ]
|
||||
|
@ -12,7 +12,7 @@ vouchers:
|
||||
- "ðis nice cookie will tell you."
|
||||
- ""
|
||||
- "&cWhat could be inside this voucher?"
|
||||
- "&6- Songoda"
|
||||
- "&6- Craftaro"
|
||||
glow: true
|
||||
confirm: true
|
||||
unbreakable: true
|
||||
|
Loading…
Reference in New Issue
Block a user