refactor: wip refactor

This commit is contained in:
darksaid98 committed 2023-11-26 17:04:56 +01:00
1 parent 99b5f7c7af
commit cd414f3508
87 files changed
+3585 -1540

No files matched your search

+435
View File
@@ -0,0 +1,435 @@
root = true
[*]
charset = utf-8
end_of_line = crlf
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 120
tab_width = 4
ij_continuation_indent_size = 4
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = true
ij_smart_tabs = false
ij_visual_guides =
ij_wrap_on_typing = false
[*.java]
ij_continuation_indent_size = 4
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_deconstruction_list_components = true
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_align_types_in_multi_catch = true
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_add_space = false
ij_java_block_comment_at_first_column = true
ij_java_builder_methods =
ij_java_call_parameters_new_line_after_left_paren = false
ij_java_call_parameters_right_paren_on_new_line = false
ij_java_call_parameters_wrap = off
ij_java_case_statement_on_separate_line = true
ij_java_catch_on_new_line = false
ij_java_class_annotation_wrap = split_into_lines
ij_java_class_brace_style = end_of_line
ij_java_class_count_to_use_import_on_demand = 5
ij_java_class_names_in_javadoc = 1
ij_java_deconstruction_list_wrap = normal
ij_java_do_not_indent_top_level_class_members = false
ij_java_do_not_wrap_after_single_annotation = false
ij_java_do_not_wrap_after_single_annotation_in_parameter = false
ij_java_do_while_brace_force = never
ij_java_doc_add_blank_line_after_description = true
ij_java_doc_add_blank_line_after_param_comments = false
ij_java_doc_add_blank_line_after_return = false
ij_java_doc_add_p_tag_on_empty_lines = true
ij_java_doc_align_exception_comments = true
ij_java_doc_align_param_comments = true
ij_java_doc_do_not_wrap_if_one_line = false
ij_java_doc_enable_formatting = true
ij_java_doc_enable_leading_asterisks = true
ij_java_doc_indent_on_continuation = false
ij_java_doc_keep_empty_lines = true
ij_java_doc_keep_empty_parameter_tag = true
ij_java_doc_keep_empty_return_tag = true
ij_java_doc_keep_empty_throws_tag = true
ij_java_doc_keep_invalid_tags = true
ij_java_doc_param_description_on_new_line = false
ij_java_doc_preserve_line_breaks = false
ij_java_doc_use_throws_not_exception_tag = true
ij_java_else_on_new_line = false
ij_java_enum_constants_wrap = off
ij_java_extends_keyword_wrap = off
ij_java_extends_list_wrap = off
ij_java_field_annotation_wrap = split_into_lines
ij_java_field_name_prefix =
ij_java_field_name_suffix =
ij_java_finally_on_new_line = false
ij_java_for_brace_force = never
ij_java_for_statement_new_line_after_left_paren = false
ij_java_for_statement_right_paren_on_new_line = false
ij_java_for_statement_wrap = off
ij_java_generate_final_locals = false
ij_java_generate_final_parameters = false
ij_java_if_brace_force = never
ij_java_imports_layout = *, |, javax.**, java.**, |, $*
ij_java_indent_case_from_switch = true
ij_java_insert_inner_class_imports = false
ij_java_insert_override_annotation = true
ij_java_keep_blank_lines_before_right_brace = 2
ij_java_keep_blank_lines_between_package_declaration_and_header = 2
ij_java_keep_blank_lines_in_code = 2
ij_java_keep_blank_lines_in_declarations = 2
ij_java_keep_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 = false
ij_java_keep_simple_lambdas_in_one_line = false
ij_java_keep_simple_methods_in_one_line = false
ij_java_label_indent_absolute = false
ij_java_label_indent_size = 0
ij_java_lambda_brace_style = end_of_line
ij_java_layout_static_imports_separately = true
ij_java_line_comment_add_space = false
ij_java_line_comment_add_space_on_reformat = false
ij_java_line_comment_at_first_column = true
ij_java_local_variable_name_prefix =
ij_java_local_variable_name_suffix =
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_multi_catch_types_wrap = normal
ij_java_names_count_to_use_import_on_demand = 3
ij_java_new_line_after_lparen_in_annotation = false
ij_java_new_line_after_lparen_in_deconstruction_pattern = true
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_parameter_name_prefix =
ij_java_parameter_name_suffix =
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_annotations =
ij_java_repeat_synchronized = true
ij_java_replace_instanceof_and_cast = false
ij_java_replace_null_check = true
ij_java_replace_sum_lambda_with_method_ref = true
ij_java_resource_list_new_line_after_left_paren = false
ij_java_resource_list_right_paren_on_new_line = false
ij_java_resource_list_wrap = off
ij_java_rparen_on_new_line_in_annotation = false
ij_java_rparen_on_new_line_in_deconstruction_pattern = true
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 = false
ij_java_space_before_catch_keyword = true
ij_java_space_before_catch_left_brace = true
ij_java_space_before_catch_parentheses = true
ij_java_space_before_class_left_brace = true
ij_java_space_before_colon = true
ij_java_space_before_colon_in_foreach = true
ij_java_space_before_comma = false
ij_java_space_before_deconstruction_list = false
ij_java_space_before_do_left_brace = true
ij_java_space_before_else_keyword = true
ij_java_space_before_else_left_brace = true
ij_java_space_before_finally_keyword = true
ij_java_space_before_finally_left_brace = true
ij_java_space_before_for_left_brace = true
ij_java_space_before_for_parentheses = true
ij_java_space_before_for_semicolon = false
ij_java_space_before_if_left_brace = true
ij_java_space_before_if_parentheses = true
ij_java_space_before_method_call_parentheses = false
ij_java_space_before_method_left_brace = true
ij_java_space_before_method_parentheses = false
ij_java_space_before_opening_angle_bracket_in_type_parameter = false
ij_java_space_before_quest = true
ij_java_space_before_switch_left_brace = true
ij_java_space_before_switch_parentheses = true
ij_java_space_before_synchronized_left_brace = true
ij_java_space_before_synchronized_parentheses = true
ij_java_space_before_try_left_brace = true
ij_java_space_before_try_parentheses = true
ij_java_space_before_type_parameter_list = false
ij_java_space_before_while_keyword = true
ij_java_space_before_while_left_brace = true
ij_java_space_before_while_parentheses = true
ij_java_space_inside_one_line_enum_braces = false
ij_java_space_within_empty_array_initializer_braces = false
ij_java_space_within_empty_method_call_parentheses = false
ij_java_space_within_empty_method_parentheses = false
ij_java_spaces_around_additive_operators = true
ij_java_spaces_around_annotation_eq = true
ij_java_spaces_around_assignment_operators = true
ij_java_spaces_around_bitwise_operators = true
ij_java_spaces_around_equality_operators = true
ij_java_spaces_around_lambda_arrow = true
ij_java_spaces_around_logical_operators = true
ij_java_spaces_around_method_ref_dbl_colon = false
ij_java_spaces_around_multiplicative_operators = true
ij_java_spaces_around_relational_operators = true
ij_java_spaces_around_shift_operators = true
ij_java_spaces_around_type_bounds_in_type_parameters = true
ij_java_spaces_around_unary_operator = false
ij_java_spaces_within_angle_brackets = false
ij_java_spaces_within_annotation_parentheses = false
ij_java_spaces_within_array_initializer_braces = false
ij_java_spaces_within_braces = false
ij_java_spaces_within_brackets = false
ij_java_spaces_within_cast_parentheses = false
ij_java_spaces_within_catch_parentheses = false
ij_java_spaces_within_deconstruction_list = false
ij_java_spaces_within_for_parentheses = false
ij_java_spaces_within_if_parentheses = false
ij_java_spaces_within_method_call_parentheses = false
ij_java_spaces_within_method_parentheses = false
ij_java_spaces_within_parentheses = false
ij_java_spaces_within_record_header = false
ij_java_spaces_within_switch_parentheses = false
ij_java_spaces_within_synchronized_parentheses = false
ij_java_spaces_within_try_parentheses = false
ij_java_spaces_within_while_parentheses = false
ij_java_special_else_if_treatment = true
ij_java_static_field_name_prefix =
ij_java_static_field_name_suffix =
ij_java_subclass_name_prefix =
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_prefix =
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
[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.jspx,*.pom,*.rng,*.tagx,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}]
ij_continuation_indent_size = 4
ij_xml_align_attributes = true
ij_xml_align_text = false
ij_xml_attribute_wrap = normal
ij_xml_block_comment_add_space = false
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
[{*.gradle.kts,*.kt,*.kts,*.main.kts,*.space.kts}]
ij_continuation_indent_size = 4
ij_kotlin_align_in_columns_case_branch = false
ij_kotlin_align_multiline_binary_operation = false
ij_kotlin_align_multiline_extends_list = false
ij_kotlin_align_multiline_method_parentheses = false
ij_kotlin_align_multiline_parameters = true
ij_kotlin_align_multiline_parameters_in_calls = false
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false
ij_kotlin_assignment_wrap = off
ij_kotlin_blank_lines_after_class_header = 0
ij_kotlin_blank_lines_around_block_when_branches = 0
ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1
ij_kotlin_block_comment_add_space = false
ij_kotlin_block_comment_at_first_column = true
ij_kotlin_call_parameters_new_line_after_left_paren = false
ij_kotlin_call_parameters_right_paren_on_new_line = false
ij_kotlin_call_parameters_wrap = off
ij_kotlin_catch_on_new_line = false
ij_kotlin_class_annotation_wrap = split_into_lines
ij_kotlin_continuation_indent_for_chained_calls = true
ij_kotlin_continuation_indent_for_expression_bodies = true
ij_kotlin_continuation_indent_in_argument_lists = true
ij_kotlin_continuation_indent_in_elvis = true
ij_kotlin_continuation_indent_in_if_conditions = true
ij_kotlin_continuation_indent_in_parameter_lists = true
ij_kotlin_continuation_indent_in_supertype_lists = true
ij_kotlin_else_on_new_line = false
ij_kotlin_enum_constants_wrap = off
ij_kotlin_extends_list_wrap = off
ij_kotlin_field_annotation_wrap = split_into_lines
ij_kotlin_finally_on_new_line = false
ij_kotlin_if_rparen_on_new_line = false
ij_kotlin_import_nested_classes = false
ij_kotlin_imports_layout = *, java.**, javax.**, kotlin.**, ^
ij_kotlin_insert_whitespaces_in_simple_one_line_method = true
ij_kotlin_keep_blank_lines_before_right_brace = 2
ij_kotlin_keep_blank_lines_in_code = 2
ij_kotlin_keep_blank_lines_in_declarations = 2
ij_kotlin_keep_first_column_comment = true
ij_kotlin_keep_indents_on_empty_lines = false
ij_kotlin_keep_line_breaks = true
ij_kotlin_lbrace_on_next_line = false
ij_kotlin_line_break_after_multiline_when_entry = true
ij_kotlin_line_comment_add_space = false
ij_kotlin_line_comment_add_space_on_reformat = false
ij_kotlin_line_comment_at_first_column = true
ij_kotlin_method_annotation_wrap = split_into_lines
ij_kotlin_method_call_chain_wrap = off
ij_kotlin_method_parameters_new_line_after_left_paren = false
ij_kotlin_method_parameters_right_paren_on_new_line = false
ij_kotlin_method_parameters_wrap = off
ij_kotlin_name_count_to_use_star_import = 5
ij_kotlin_name_count_to_use_star_import_for_members = 3
ij_kotlin_packages_to_use_import_on_demand = java.util.*, kotlinx.android.synthetic.**, io.ktor.**
ij_kotlin_parameter_annotation_wrap = off
ij_kotlin_space_after_comma = true
ij_kotlin_space_after_extend_colon = true
ij_kotlin_space_after_type_colon = true
ij_kotlin_space_before_catch_parentheses = true
ij_kotlin_space_before_comma = false
ij_kotlin_space_before_extend_colon = true
ij_kotlin_space_before_for_parentheses = true
ij_kotlin_space_before_if_parentheses = true
ij_kotlin_space_before_lambda_arrow = true
ij_kotlin_space_before_type_colon = false
ij_kotlin_space_before_when_parentheses = true
ij_kotlin_space_before_while_parentheses = true
ij_kotlin_spaces_around_additive_operators = true
ij_kotlin_spaces_around_assignment_operators = true
ij_kotlin_spaces_around_equality_operators = true
ij_kotlin_spaces_around_function_type_arrow = true
ij_kotlin_spaces_around_logical_operators = true
ij_kotlin_spaces_around_multiplicative_operators = true
ij_kotlin_spaces_around_range = false
ij_kotlin_spaces_around_relational_operators = true
ij_kotlin_spaces_around_unary_operator = false
ij_kotlin_spaces_around_when_arrow = true
ij_kotlin_variable_annotation_wrap = off
ij_kotlin_while_on_new_line = false
ij_kotlin_wrap_elvis_expressions = 1
ij_kotlin_wrap_expression_body_functions = 0
ij_kotlin_wrap_first_method_in_call_chain = false
[{*.har,*.json,*.png.mcmeta,mcmod.info,pack.mcmeta}]
indent_size = 2
ij_continuation_indent_size = 4
ij_json_array_wrapping = split_into_lines
ij_json_keep_blank_lines_in_code = 0
ij_json_keep_indents_on_empty_lines = false
ij_json_keep_line_breaks = true
ij_json_keep_trailing_comma = false
ij_json_object_wrapping = split_into_lines
ij_json_property_alignment = do_not_align
ij_json_space_after_colon = true
ij_json_space_after_comma = true
ij_json_space_before_colon = false
ij_json_space_before_comma = false
ij_json_spaces_within_braces = false
ij_json_spaces_within_brackets = false
ij_json_wrap_long_lines = false
[{*.markdown,*.md,*.md }]
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_format_tables = true
ij_markdown_insert_quote_arrows_on_wrap = true
ij_markdown_keep_indents_on_empty_lines = false
ij_markdown_keep_line_breaks_inside_text_blocks = true
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
ij_markdown_wrap_text_if_long = true
ij_markdown_wrap_text_inside_blockquotes = true
[{*.toml,Cargo.lock,Cargo.toml.orig,Gopkg.lock,Pipfile,poetry.lock}]
ij_continuation_indent_size = 4
ij_toml_keep_indents_on_empty_lines = false
[{*.yaml,*.yml}]
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
+2
View File
@@ -0,0 +1,2 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
+1
View File
@@ -0,0 +1 @@
* @darksaid98
+1
View File
@@ -0,0 +1 @@
github: darksaid98
+34
View File
@@ -0,0 +1,34 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Version information:**
- Vanilla version: [e.g. 1.20.2]
- Server version: [e.g. paper-123]
- Plugin version [e.g. 0.1.0]
**Additional context**
```
Add any other context about the problem here including console errors.
```
+20
View File
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
+15
View File
@@ -0,0 +1,15 @@
name: 'Setup Gradle'
description: 'Grant execute permissions and validate Gradle wrapper'
runs:
using: 'composite'
steps:
- name: Grant execute permissions for Gradle wrapper
run: chmod +x gradlew
shell: bash
- name: Validate Gradle Wrapper Authenticity
uses: gradle/wrapper-validation-action@v1
- name: Setup Gradle and Caching
uses: gradle/gradle-build-action@v2
+17
View File
@@ -0,0 +1,17 @@
name: 'Setup JDK'
description: 'Set up JDK'
inputs:
java-version:
description: 'Java version'
required: true
default: '17'
runs:
using: 'composite'
steps:
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: ${{ inputs.java-version }}
distribution: 'temurin'
+16
View File
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "ci:"
target-branch: "main"
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "build:"
target-branch: "main"
+93
View File
@@ -0,0 +1,93 @@
name: Build & Upload Release jar with Gradle
on:
push:
branches:
- 'main'
- 'master'
tags:
- '*'
pull_request:
branches:
- 'main'
- 'master'
schedule:
- cron: '0 0 * * 6'
workflow_dispatch:
concurrency:
group: ${{ format('{0}-{1}', github.job, github.ref) }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
java: [ 17 ]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Gradle
uses: ./.github/actions/gradle
- name: Setup JDK
uses: ./.github/actions/jdk
with:
java-version: ${{ matrix.java }}
- name: Build with Gradle
run: ./gradlew clean build --info
- name: Upload build results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }} Java ${{ matrix.java }} Snapshot
path: ${{ github.workspace }}/build/libs/
release:
needs:
- build
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 17 ]
if: github.ref_type == 'tag' || ((github.ref_name == 'main' || github.ref_name == 'master') && github.event_name != 'schedule')
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Gradle
uses: ./.github/actions/gradle
- name: Setup JDK
uses: ./.github/actions/jdk
with:
java-version: ${{ matrix.java }}
- name: Set Release Environment Variable
if: github.ref_type == 'tag'
run: |
echo "CUSTOM_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Build with Gradle
if: github.ref_type != 'tag'
run: ./gradlew clean build
- name: Build with Gradle
if: github.ref_type == 'tag'
run: ./gradlew clean build -PcustomVersion=${{ env.CUSTOM_VERSION }}
- name: Create Release
uses: softprops/action-gh-release@v1
id: release
if: github.ref_type == 'tag'
with:
name: ${{ format('Release {0}', github.ref_name) }}
files: ${{ github.workspace }}/build/libs/*
prerelease: ${{ contains(github.ref_name, '-RC-') }}
generate_release_notes: true
fail_on_unmatched_files: true
draft: false
+26
View File
@@ -0,0 +1,26 @@
name: 'Close Stale Issues & PRs'
on:
schedule:
- cron: '30 1 * * *'
permissions:
contents: read
issues: write
pull-requests: write
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
with:
stale-issue-message: ' This issue has been automatically marked as stale because it has been open for 60 days with no activity.'
stale-pr-message: 'This PR has been automatically marked as stale because it has been open for 60 days with no activity.'
close-issue-message: 'This issue was closed because it has been stalled for -1 days with no activity.'
close-pr-message: 'This PR was closed because it has been stalled for -1 days with no activity.'
days-before-issue-stale: 60
days-before-pr-stale: 60
days-before-issue-close: -1
days-before-pr-close: -1
stale-issue-label: 'stale'
stale-pr-label: 'stale'
+86
View File
@@ -0,0 +1,86 @@
##############################
## Java
##############################
.mtj.tmp/
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*
replay_pid*
##############################
## Maven
##############################
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
pom.xml.bak
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
##############################
## Gradle
##############################
bin/
build/
.gradle
.gradletasknamecache
gradle-app.setting
!gradle-wrapper.jar
##############################
## IntelliJ
##############################
out/
.idea/
.idea_modules/
*.iml
*.ipr
*.iws
##############################
## Eclipse
##############################
.settings/
bin/
tmp/
.metadata
.classpath
.project
*.tmp
*.bak
*.swp
*~.nib
local.properties
.loadpath
.factorypath
##############################
## NetBeans
##############################
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
##############################
## Visual Studio Code
##############################
.vscode/
.code-workspace
##############################
## OS X
##############################
.DS_Store
/run/
+132
View File
@@ -0,0 +1,132 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
alathraserver@gmail.com.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of
actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the
community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
+44
View File
@@ -0,0 +1,44 @@
## Pull Requests
We use the [GitHub flow](https://guides.github.com/introduction/flow/) for contributions.
1. Fork the repository.
2. Create a new branch for each feature, fix or improvement.
3. Send a pull request from each feature branch to the **main** branch.
It is very important to separate new features or improvements into separate feature branches, and to send a pull request for each branch. This allow us to review and pull in new features or improvements individually.
## Specifications
### Commit Messages
All commit messages should adhere to the [Conventional Commits specification](https://conventionalcommits.org/).
#### Commit Types
- API relevant changes
* `feat` Commits, that adds a new feature
* `fix` Commits, that fixes a bug/issue
- `refactor` Commits, that rewrite/restructure your code, however does not change any API behaviour
* `perf` Commits are special `refactor` commits, that improve performance
- `style` Commits, that do not affect the meaning (white-space, formatting, missing semi-colons, etc)
- `test` Commits, that add or correct existing tests
- `docs` Commits, that affect documentation only
- Tooling relevant changes
* `build` Commits, that affect build components like build tool, dependencies, project version, ...
* `ci` Commits, that affect CI configuration files and scripts
- `revert` Commits, that revert previous commits
- `chore` Miscellaneous commits without production code change, e.g. modifying `.gitignore`
### Versioning
Our project adheres to the [Semantic Versioning 2.0.0 specification](https://semver.org/) for versioning.
### Style Guide
Large refactors breaking the style defined in the `.editorconfig` file are frowned upon.
When contributing ensure your code follows existing conventions and styling. (*Any issues that arise will be noted in your pull request.*)
## Licensing
You must agree that your patch will be licensed under the main license found in this repository, and if we change the license, we will assume that you agreed with the change unless you object to the changes in time.
-39
View File
@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
-1
View File
@@ -1 +0,0 @@
/target/
-23
View File
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ClickTpa</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
@@ -1,11 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
@@ -1,4 +0,0 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
-39
View File
@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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.jklmao.plugin</groupId>
<artifactId>ClickTpa</artifactId>
<version>1.7.1v</version>
<packaging>jar</packaging>
<name>ClickTpa</name>
<description>Simple TPA plugin for Spigot/Paper Software</description>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -1,73 +0,0 @@
package com.jklmao.plugin;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import com.jklmao.plugin.commands.CommandReload;
import com.jklmao.plugin.commands.CommandTpCancel;
import com.jklmao.plugin.commands.CommandTpToggle;
import com.jklmao.plugin.commands.CommandTpa;
import com.jklmao.plugin.commands.CommandTpaDeny;
import com.jklmao.plugin.commands.CommandTpaHere;
import com.jklmao.plugin.commands.CommandTpaccept;
import com.jklmao.plugin.commands.CommandTpo;
import com.jklmao.plugin.commands.CommandTpoHere;
import com.jklmao.plugin.events.PlayerEvents;
import com.jklmao.plugin.utils.CustomList;
public final class ClickTpa extends JavaPlugin {
private HashSet<Player> graceList = new HashSet<>();
private HashMap<Player, Player> tpaCancel = new HashMap<>();
private HashMap<Player, CustomList> playerTpaList = new HashMap<>();
@Override
public void onEnable() {
commandHandler();
addAllPlayers();
saveDefaultConfig();
getServer().getPluginManager().registerEvents(new PlayerEvents(this), this);
getLogger().info("ClickTPA has been loaded Successfully!");
}
public HashSet<Player> getGraceList() {
return this.graceList;
}
public HashMap<Player, Player> getTpaCancel() {
return tpaCancel;
}
public HashMap<Player, CustomList> getTpaPlayers() {
return this.playerTpaList;
}
private void commandHandler() {
getCommand("tpa").setExecutor(new CommandTpa(this));
getCommand("tpahere").setExecutor(new CommandTpaHere(this));
getCommand("tpacancel").setExecutor(new CommandTpCancel(this));
getCommand("tpaccept").setExecutor(new CommandTpaccept(this));
getCommand("tpdeny").setExecutor(new CommandTpaDeny(this));
getCommand("tpo").setExecutor(new CommandTpo(this));
getCommand("tpohere").setExecutor(new CommandTpoHere(this));
getCommand("tptoggle").setExecutor(new CommandTpToggle(this));
getCommand("clicktparl").setExecutor(new CommandReload(this));
}
private void addAllPlayers() {
CustomList list = new CustomList();
for (Player p : Bukkit.getOnlinePlayers()) {
playerTpaList.put(p, list);
}
}
}
@@ -1,44 +0,0 @@
package com.jklmao.plugin.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.utils.ConfigUtil;
public class CommandReload implements CommandExecutor, ConfigUtil {
private ClickTpa clicktpa;
final private String prefix = "&4&l[Click&b&lTpa]";
public CommandReload(ClickTpa pl) {
clicktpa = pl;
clicktpa.saveDefaultConfig();
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (!p.hasPermission("clicktpa.reload")) {
p.sendMessage(getMsg("Insufficient-permission"));
return true;
}
}
clicktpa.saveDefaultConfig();
clicktpa.reloadConfig();
sender.sendMessage(colorize(prefix + " &aThe plugin's config has been reloaded!"));
return true;
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,79 +0,0 @@
package com.jklmao.plugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.utils.ConfigUtil;
import com.jklmao.plugin.utils.TpaInfoList;
public class CommandTpCancel implements CommandExecutor, ConfigUtil {
private ClickTpa clicktpa;
public CommandTpCancel(ClickTpa pl) {
clicktpa = pl;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (!p.hasPermission("clicktpa.tpacancel")) {
p.sendMessage(getMsg("Insufficient-permission"));
return true;
}
if (clicktpa.getTpaCancel().containsKey(p)) {
Player poorRejectedGuy = Bukkit.getServer().getPlayer(clicktpa.getTpaCancel().get(p).getName());
if (poorRejectedGuy == null) {
p.sendMessage(getMsg("Tpacancel-message"));
clicktpa.getTpaCancel().remove(p);
return true;
}
if (poorRejectedGuy.isOnline()) {
p.sendMessage(getMsg("Tpacancel-message"));
poorRejectedGuy.sendMessage(getMsg("Tpacancel-message"));
removeTpaInfo(p, poorRejectedGuy);
return true;
}
p.sendMessage(getMsg("Tpacancel-message"));
removeTpaInfo(p, poorRejectedGuy);
return true;
} else {
p.sendMessage(getMsg("Player-no-pendingtpa-message"));
return true;
}
}
sender.sendMessage(getMsg("Player-only-command"));
return true;
}
private void removeTpaInfo(Player p, Player target) {
for (TpaInfoList list : clicktpa.getTpaPlayers().get(target).getTpaList()) {
if (list.getRequester() == p) {
clicktpa.getTpaPlayers().get(target).getTpaList().remove(list);
clicktpa.getTpaCancel().remove(p);
return;
}
}
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,59 +0,0 @@
package com.jklmao.plugin.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.enums.TeleportMode;
import com.jklmao.plugin.utils.ConfigUtil;
public class CommandTpToggle implements CommandExecutor, ConfigUtil {
private ClickTpa clicktpa;
public CommandTpToggle(ClickTpa pl) {
clicktpa = pl;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (!p.hasPermission("clicktpa.tptoggle")) {
p.sendMessage(getMsg("Insufficient-permission"));
return true;
}
if (p.hasPermission("clicktpa.tptoggle")) {
TeleportMode mode = clicktpa.getTpaPlayers().get(p).getMode();
switch (mode) {
case DEFAULT:
// turn on tptoggle
clicktpa.getTpaPlayers().get(p).setMode(TeleportMode.TPTOGGLE_ON);
p.sendMessage(getMsg("Player-TpToggle-On"));
break;
case TPTOGGLE_ON:
clicktpa.getTpaPlayers().get(p).setMode(TeleportMode.DEFAULT);
p.sendMessage(getMsg("Player-TpToggle-Off"));
break;
case TELEPORTING:
p.sendMessage(getMsg("TpToggle-While-Teleporting"));
break;
}
return true;
}
}
sender.sendMessage(getMsg("Player-only-command"));
return true;
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,92 +0,0 @@
package com.jklmao.plugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.enums.TeleportMode;
import com.jklmao.plugin.enums.TeleportType;
import com.jklmao.plugin.events.RequestExpireListener;
import com.jklmao.plugin.utils.ConfigUtil;
import com.jklmao.plugin.utils.TeleportMsgs;
import com.jklmao.plugin.utils.TpaInfoList;
public class CommandTpa implements CommandExecutor, ConfigUtil {
private ClickTpa clicktpa;
private TeleportMsgs msgs;
public CommandTpa(ClickTpa pl) {
clicktpa = pl;
msgs = new TeleportMsgs(clicktpa);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(getMsg("Player-only-command"));
return true;
}
final Player p = (Player) sender;
if (!p.hasPermission("clicktpa.tpa")) {
p.sendMessage(getMsg("Insufficient-permission"));
return true;
}
if (args.length == 0) {
p.sendMessage(getMsg("Tpa-usage"));
return true;
}
final Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
p.sendMessage(getMsg("No-player-found"));
return true;
}
if (target == p) {
p.sendMessage(getMsg("Player-teleporting-self"));
return true;
}
if (clicktpa.getTpaPlayers().get(p).getMode() == TeleportMode.TPTOGGLE_ON) {
p.sendMessage(getMsg("Player-Is-TpToggled"));
return true;
}
if (clicktpa.getTpaPlayers().get(target).getMode() == TeleportMode.TPTOGGLE_ON) {
p.sendMessage(getMsg("Target-Is-TpToggled").replaceAll("%target%", target.getName()));
return true;
}
if (clicktpa.getTpaPlayers().get(p).getMode() == TeleportMode.DEFAULT) {
for (TpaInfoList list : clicktpa.getTpaPlayers().get(target).getTpaList()) {
if (list.getRequester() == p) {
p.sendMessage(getMsg("Player-already-requested"));
return true;
}
}
// create a new tpa info
TpaInfoList info = new TpaInfoList(TeleportType.TPA, p);
clicktpa.getTpaPlayers().get(target).getTpaList().add(info);
clicktpa.getTpaCancel().put(p, target);
msgs.sendRequestMsg(TeleportType.TPA, p, target);
//
RequestExpireListener expireTimer = new RequestExpireListener(clicktpa, info);
expireTimer.startTimer(p, target);
//
return true;
}
return true;
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,76 +0,0 @@
package com.jklmao.plugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.utils.ConfigUtil;
import com.jklmao.plugin.utils.TpaInfoList;
public class CommandTpaDeny implements CommandExecutor, ConfigUtil {
private ClickTpa clicktpa;
public CommandTpaDeny(ClickTpa pl) {
clicktpa = pl;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (!p.hasPermission("clicktpa.tpadeny")) {
p.sendMessage(getMsg("Insufficient-permission"));
return true;
}
if (args.length == 0) {
p.sendMessage(getMsg("Tpdeny-usage"));
return true;
}
final Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
p.sendMessage(getMsg("No-player-found"));
return true;
}
if (target.isOnline()) {
boolean hasRequester = false;
for (TpaInfoList list : clicktpa.getTpaPlayers().get(p).getTpaList()) {
if (list.getRequester() == target) {
clicktpa.getTpaPlayers().get(p).getTpaList().remove(list);
clicktpa.getTpaCancel().remove(target);
hasRequester = true;
break;
}
}
if (hasRequester) {
p.sendMessage(getMsg("Player-deny-tpa-message"));
target.sendMessage(getMsg("Target-deny-tpa-message"));
clicktpa.getTpaCancel().remove(target);
return true;
} else {
p.sendMessage(getMsg("Player-no-pendingtpa-message"));
return true;
}
} else {
p.sendMessage(getMsg("Target-is-offline"));
return true;
}
}
sender.sendMessage(getMsg("Player-only-command"));
return true;
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,91 +0,0 @@
package com.jklmao.plugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.enums.TeleportMode;
import com.jklmao.plugin.enums.TeleportType;
import com.jklmao.plugin.events.RequestExpireListener;
import com.jklmao.plugin.utils.ConfigUtil;
import com.jklmao.plugin.utils.TeleportMsgs;
import com.jklmao.plugin.utils.TpaInfoList;
public class CommandTpaHere implements CommandExecutor, ConfigUtil {
private ClickTpa clicktpa;
private TeleportMsgs msgs;
public CommandTpaHere(ClickTpa pl) {
clicktpa = pl;
msgs = new TeleportMsgs(clicktpa);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(getMsg("Player-only-command"));
return true;
}
final Player p = (Player) sender;
if (!p.hasPermission("clicktpa.tpahere")) {
p.sendMessage(getMsg("Insufficient-permission"));
return true;
}
if (args.length == 0) {
p.sendMessage(getMsg("Tpahere-usage"));
return true;
}
final Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
p.sendMessage(getMsg("No-player-found"));
return true;
}
if (target == p) {
p.sendMessage(getMsg("Player-teleporting-self"));
return true;
}
if (clicktpa.getTpaPlayers().get(p).getMode() == TeleportMode.TPTOGGLE_ON) {
p.sendMessage(getMsg("Player-Is-TpToggled"));
return true;
}
if (clicktpa.getTpaPlayers().get(target).getMode() == TeleportMode.TPTOGGLE_ON) {
p.sendMessage(getMsg("Target-Is-TpToggled").replaceAll("%target%", target.getName()));
return true;
}
if (clicktpa.getTpaPlayers().get(p).getMode() == TeleportMode.DEFAULT) {
for (TpaInfoList list : clicktpa.getTpaPlayers().get(target).getTpaList()) {
if (list.getRequester() == p) {
p.sendMessage(getMsg("Player-already-requested"));
return true;
}
}
// create a new tpa info
TpaInfoList info = new TpaInfoList(TeleportType.TPAHERE, p);
clicktpa.getTpaPlayers().get(target).getTpaList().add(info);
clicktpa.getTpaCancel().put(p, target);
msgs.sendRequestMsg(TeleportType.TPAHERE, p, target);
//
RequestExpireListener expireTimer = new RequestExpireListener(clicktpa, info);
expireTimer.startTimer(p, target);
//
return true;
}
return true;
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,122 +0,0 @@
package com.jklmao.plugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.enums.TeleportMode;
import com.jklmao.plugin.enums.TeleportType;
import com.jklmao.plugin.events.TpaCountdownListener;
import com.jklmao.plugin.utils.ConfigUtil;
import com.jklmao.plugin.utils.TpaInfoList;
public class CommandTpaccept implements CommandExecutor, ConfigUtil {
private ClickTpa clicktpa;
public CommandTpaccept(ClickTpa pl) {
clicktpa = pl;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
int seconds = clicktpa.getConfig().getInt("Seconds-until-tpa");
if (!(sender instanceof Player)) {
sender.sendMessage(getMsg("Player-only-command"));
return true;
}
Player p = (Player) sender;
if (!p.hasPermission("clicktpa.tpaccept")) {
p.sendMessage(getMsg("Insufficient-permission"));
return true;
}
if (args.length == 0) {
p.sendMessage(getMsg("Tpaccept-usage"));
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
p.sendMessage(getMsg("No-player-found"));
return true;
}
if (!target.isOnline()) {
p.sendMessage(getMsg("Target-is-offline"));
for (TpaInfoList list : clicktpa.getTpaPlayers().get(p).getTpaList()) {
if (list.getRequester() == target) {
clicktpa.getTpaPlayers().get(p).getTpaList().remove(list);
clicktpa.getTpaCancel().remove(target);
return true;
}
}
}
if (clicktpa.getTpaPlayers().get(p).getTpaList().isEmpty()) {
p.sendMessage(getMsg("Player-no-pendingtpa-message"));
return true;
}
TpaInfoList tpaInfo = null;
if (clicktpa.getTpaPlayers().get(p).getTpaList().size() > 0) {
boolean hasRequester = false;
for (TpaInfoList list : clicktpa.getTpaPlayers().get(p).getTpaList()) {
if (list.getRequester() == target) {
hasRequester = true;
tpaInfo = list;
break;
}
}
if (!hasRequester) {
p.sendMessage(getMsg("Player-no-pendingtpa-message"));
return true;
}
}
p.sendMessage(getMsg("Player-got-accepted-tpa"));
target.sendMessage(getMsg("Target-accepted-tpa-request"));
TpaCountdownListener cdListener = new TpaCountdownListener(clicktpa);
switch (tpaInfo.getType()) {
case TPA:
target.sendMessage(getMsg("Countdown-until-tpa"));
clicktpa.getTpaPlayers().get(target).setMode(TeleportMode.TELEPORTING);
clicktpa.getGraceList().add(target);
cdListener.tpaCountdown(seconds, TeleportType.TPA, p, target);
break;
case TPAHERE:
p.sendMessage(getMsg("Countdown-until-tpa"));
clicktpa.getTpaPlayers().get(p).setMode(TeleportMode.TELEPORTING);
clicktpa.getGraceList().add(p);
cdListener.tpaCountdown(seconds, TeleportType.TPAHERE, p, target);
break;
}
clicktpa.getTpaCancel().remove(target);
return true;
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,55 +0,0 @@
package com.jklmao.plugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.utils.ConfigUtil;
public class CommandTpo implements CommandExecutor, ConfigUtil {
private ClickTpa clicktpa;
public CommandTpo(ClickTpa pl) {
clicktpa = pl;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (!p.hasPermission("clicktpa.tpo")) {
p.sendMessage(getMsg("Insufficient-permission"));
return true;
}
if (args.length == 0) {
p.sendMessage(getMsg("Tpo-usage"));
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
p.sendMessage(getMsg("No-player-found"));
return true;
}
if (target.equals(p)) {
p.sendMessage(getMsg("Player-teleporting-self"));
return true;
}
p.sendMessage(getMsg("Player-currently-teleporting"));
target.sendMessage(getMsg("Target-currently-teleporting"));
p.teleport(target);
return true;
}
sender.sendMessage(getMsg("Player-only-command"));
return true;
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,55 +0,0 @@
package com.jklmao.plugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.utils.ConfigUtil;
public class CommandTpoHere implements CommandExecutor, ConfigUtil {
private ClickTpa clicktpa;
public CommandTpoHere(ClickTpa pl) {
clicktpa = pl;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (!p.hasPermission("clicktpa.tpohere")) {
p.sendMessage(getMsg("Insufficient-permission"));
return true;
}
if (args.length == 0) {
p.sendMessage(getMsg("Tpohere-usage"));
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
p.sendMessage(getMsg("No-player-found"));
return true;
}
if (target.equals(p)) {
p.sendMessage(getMsg("Player-teleporting-self"));
return true;
}
p.sendMessage(getMsg("Player-currently-teleporting"));
target.teleport(p);
target.sendMessage(getMsg("Target-currently-teleporting"));
return true;
}
sender.sendMessage(getMsg("Player-only-command"));
return true;
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,7 +0,0 @@
package com.jklmao.plugin.enums;
public enum TeleportMode {
DEFAULT, TELEPORTING, TPTOGGLE_ON
}
@@ -1,7 +0,0 @@
package com.jklmao.plugin.enums;
public enum TeleportType {
TPA, TPAHERE
}
@@ -1,49 +0,0 @@
package com.jklmao.plugin.events;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.enums.TeleportMode;
import com.jklmao.plugin.utils.CustomList;
public class PlayerEvents implements Listener {
private ClickTpa clicktpa;
public PlayerEvents(ClickTpa pl) {
clicktpa = pl;
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
CustomList list = new CustomList();
clicktpa.getTpaPlayers().put(e.getPlayer(), list);
}
@EventHandler
public void onLeave(PlayerQuitEvent e) {
clicktpa.getTpaPlayers().remove(e.getPlayer());
}
@EventHandler
public void onMove(PlayerMoveEvent e) {
if (clicktpa.getConfig().getBoolean("Allow-player-to-move"))
return;
Player p = e.getPlayer();
if (!clicktpa.getGraceList().contains(p))
return;
if (clicktpa.getGraceList().contains(p)) {
if (e.getFrom().getBlockX() != e.getTo().getBlockX() || e.getFrom().getBlockZ() != e.getTo().getBlockZ()) {
clicktpa.getGraceList().remove(p);
clicktpa.getTpaPlayers().get(p).setMode(TeleportMode.DEFAULT);
}
}
}
}
@@ -1,82 +0,0 @@
package com.jklmao.plugin.events;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.enums.TeleportMode;
import com.jklmao.plugin.utils.ConfigUtil;
import com.jklmao.plugin.utils.TpaInfoList;
public class RequestExpireListener implements ConfigUtil {
private ClickTpa clicktpa;
private TpaInfoList info;
//
private BukkitTask task;
public RequestExpireListener(ClickTpa plugin, TpaInfoList tpaInfo) {
clicktpa = plugin;
info = tpaInfo;
}
public void startTimer(Player p, Player target) {
task = Bukkit.getScheduler().runTaskTimer(clicktpa, new Runnable() {
int time = clicktpa.getConfig().getInt("Request-expire-time") * 4;
@Override
public void run() {
if (!p.isOnline()) {
task.cancel();
task = null;
return;
}
if (time == 0) {
task.cancel();
p.sendMessage(getMsg("Player-teleportation-request-expire"));
target.sendMessage(getMsg("Target-teleportation-request-expire"));
// expired request
clicktpa.getTpaPlayers().get(target).getTpaList().remove(info);
clicktpa.getTpaPlayers().get(p).setMode(TeleportMode.DEFAULT);
task = null;
return;
}
if (!target.isOnline()) {
task.cancel();
task = null;
return;
} else {
if (!clicktpa.getTpaPlayers().get(target).getTpaList().contains(info)) {
task.cancel();
task = null;
return;
}
if (clicktpa.getTpaPlayers().get(p).getMode() == TeleportMode.TELEPORTING) {
task.cancel();
task = null;
return;
}
}
time = time - 1;
}
}, 0, 5);
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,147 +0,0 @@
package com.jklmao.plugin.events;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.enums.TeleportMode;
import com.jklmao.plugin.enums.TeleportType;
import com.jklmao.plugin.utils.TeleportMsgs;
import com.jklmao.plugin.utils.TpaInfoList;
public class TpaCountdownListener {
private ClickTpa clicktpa;
private TeleportMsgs tpMsgs;
private BukkitTask cdTask;
public TpaCountdownListener(ClickTpa plugin) {
clicktpa = plugin;
tpMsgs = new TeleportMsgs(clicktpa);
}
public void tpaCountdown(int secs, TeleportType type, Player sender, Player target) {
switch (type) {
case TPA:
tpMsgs.currentlyTeleportingTitle(secs, target);
break;
case TPAHERE:
tpMsgs.currentlyTeleportingTitle(secs, sender);
break;
}
cdTask = Bukkit.getScheduler().runTaskTimer(clicktpa, new Runnable() {
int time = secs * 2;
@Override
public void run() {
if (disconnectListener(sender, target)) {
return;
}
moveListener(type, sender, target);
if (time == 0) {
if (disconnectListener(sender, target)) {
return;
}
teleport(type, sender, target);
cdTask.cancel();
}
time = time - 1;
}
}, 0, 10);
}
private void teleport(TeleportType type, Player sender, Player target) {
switch (type) {
case TPA:
target.teleport(sender);
tpMsgs.successfulTPATitle(target, sender);
clicktpa.getTpaPlayers().get(target).setMode(TeleportMode.DEFAULT);
break;
case TPAHERE:
sender.teleport(target);
tpMsgs.successfulTPATitle(sender, target);
clicktpa.getTpaPlayers().get(sender).setMode(TeleportMode.DEFAULT);
break;
}
removeTpaInfo(sender, target);
}
private void moveListener(TeleportType type, Player sender, Player target) {
switch (type) {
case TPA:
if (!clicktpa.getGraceList().contains(target)) {
cdTask.cancel();
tpMsgs.sendMoveBeforeTPATitle(sender, target);
removeTpaInfo(sender, target);
}
return;
case TPAHERE:
if (!clicktpa.getGraceList().contains(sender)) {
cdTask.cancel();
tpMsgs.sendMoveBeforeTPAHERETitle(sender, target);
removeTpaInfo(sender, target);
}
return;
}
}
private boolean disconnectListener(Player sender, Player target) {
if (!sender.isOnline()) {
cdTask.cancel();
cdTask = null;
target.sendMessage(tpMsgs.getMsg("Target-teleportion-canceled"));
clicktpa.getGraceList().remove(target);
clicktpa.getTpaPlayers().get(target).setMode(TeleportMode.DEFAULT);
return true;
}
if (!target.isOnline()) {
cdTask.cancel();
cdTask = null;
sender.sendMessage(tpMsgs.getMsg("Target-teleportion-canceled"));
clicktpa.getGraceList().remove(sender);
clicktpa.getTpaPlayers().get(sender).setMode(TeleportMode.DEFAULT);
return true;
}
return false;
}
private void removeTpaInfo(Player sender, Player target) {
for (TpaInfoList tpaInfo : clicktpa.getTpaPlayers().get(sender).getTpaList()) {
if (tpaInfo.getRequester() != target) {
continue;
} else {
clicktpa.getTpaPlayers().get(sender).getTpaList().remove(tpaInfo);
return;
}
}
}
}
@@ -1,15 +0,0 @@
package com.jklmao.plugin.utils;
import net.md_5.bungee.api.ChatColor;
public interface ConfigUtil {
default String getMsg(String path) {
return null;
}
default String colorize(String message) {
return ChatColor.translateAlternateColorCodes('&', message);
}
}
@@ -1,25 +0,0 @@
package com.jklmao.plugin.utils;
import java.util.ArrayList;
import java.util.List;
import com.jklmao.plugin.enums.TeleportMode;
public class CustomList {
private List<TpaInfoList> tpaList = new ArrayList<>();
private TeleportMode mode = TeleportMode.DEFAULT;
public TeleportMode getMode() {
return mode;
}
public void setMode(TeleportMode mode) {
this.mode = mode;
}
public List<TpaInfoList> getTpaList() {
return tpaList;
}
}
@@ -1,124 +0,0 @@
package com.jklmao.plugin.utils;
import java.util.List;
import org.bukkit.entity.Player;
import com.jklmao.plugin.ClickTpa;
import com.jklmao.plugin.enums.TeleportType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.hover.content.Content;
import net.md_5.bungee.api.chat.hover.content.Text;
public class TeleportMsgs implements ConfigUtil {
private ClickTpa clicktpa;
public TeleportMsgs(ClickTpa plugin) {
clicktpa = plugin;
}
public void sendRequestMsg(TeleportType type, Player player, Player target) {
TextComponent accept = new TextComponent(getMsg("Click-to-accept"));
Text acceptHoverText = new Text(getMsg("Hover-message-on-accept"));
accept.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Content[] { acceptHoverText }));
accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tpaccept " + player.getName()));
TextComponent deny = new TextComponent(getMsg("Click-to-deny"));
Text denyHoverText = new Text(getMsg("Hover-message-on-deny"));
deny.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Content[] { denyHoverText }));
deny.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tpadeny " + player.getName()));
String requestsent = getMsg("Player-sent-request").replaceAll("%target%", target.getName());
List<String> tpa = null;
switch (type) {
case TPA:
tpa = clicktpa.getConfig().getStringList("Tpa-message");
break;
case TPAHERE:
tpa = clicktpa.getConfig().getStringList("Tpahere-message");
break;
}
for (String m : tpa) {
target.sendMessage(
colorize(m).replaceAll("%player%", player.getName()).replaceAll("%accept%", accept.getText()).replaceAll("%deny%", deny.getText()));
}
if (clicktpa.getConfig().getBoolean("Center-accept-deny-msg")) {
TextComponent eemptyspace = new TextComponent(" ");
TextComponent bemptyspace = new TextComponent(" ");
target.spigot().sendMessage(new BaseComponent[] { bemptyspace, accept, eemptyspace, deny });
player.sendMessage(requestsent);
} else {
TextComponent emptyspace = new TextComponent(" ");
target.spigot().sendMessage(new BaseComponent[] { accept, emptyspace, deny });
player.sendMessage(requestsent);
}
}
public void successfulTPATitle(Player teleporter, Player waiter) {
if (doSendTitle()) {
String successMsg = getMsg("On-screen-teleported");
teleporter.sendTitle(successMsg, "", 1, 20, 1);
}
teleporter.sendMessage(getMsg("Target-currently-teleporting"));
waiter.sendMessage(getMsg("Player-currently-teleporting"));
}
public void currentlyTeleportingTitle(int secs, Player teleporter) {
if (doSendTitle()) {
String mainTitle = clicktpa.getConfig().getStringList("On-screen-teleporting").get(0);
String subTitle = clicktpa.getConfig().getStringList("On-screen-teleporting").get(1);
teleporter.sendTitle(colorize(mainTitle), colorize(subTitle), 1, secs * 20, 1);
}
}
public void sendMoveBeforeTPAHERETitle(Player player, Player target) {
if (doSendTitle()) {
String cancelMsg = getMsg("On-screen-canceled-tp");
player.sendTitle(cancelMsg, "", 1, 30, 1);
}
target.sendMessage(getMsg("Player-moved-before-tp").replaceAll("%player%", player.getName()));
player.sendMessage(getMsg("Player-moved-before-tp").replaceAll("%player%", player.getName()));
}
public void sendMoveBeforeTPATitle(Player player, Player target) {
if (doSendTitle()) {
String cancelMsg = getMsg("On-screen-canceled-tp");
target.sendTitle(cancelMsg, "", 1, 30, 1);
}
target.sendMessage(getMsg("Player-moved-before-tp").replaceAll("%player%", target.getName()));
player.sendMessage(getMsg("Player-moved-before-tp").replaceAll("%player%", target.getName()));
}
private boolean doSendTitle() {
return clicktpa.getConfig().getBoolean("Send-on-screen-message");
}
@Override
public String getMsg(String path) {
return colorize(clicktpa.getConfig().getString(path));
}
}
@@ -1,24 +0,0 @@
package com.jklmao.plugin.utils;
import org.bukkit.entity.Player;
import com.jklmao.plugin.enums.TeleportType;
public class TpaInfoList {
private TeleportType type;
private Player target;
public TpaInfoList(TeleportType t, Player p) {
type = t;
target = p;
}
public Player getRequester() {
return target;
}
public TeleportType getType() {
return type;
}
}
-162
View File
@@ -1,162 +0,0 @@
# Config for ClickTpa
# Version v1.7.1
# Author: jklmao
# # # # # # # # # # # # # # # # # # # # # # # # #
# #
# ClickTpa Config #
# #
# # # # # # # # # # # # # # # # # # # # # # # # #
# Be aware of all warnings! #
# # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Place Holders #
# #
# # # # # # # # # # # # # # # # # # # # # # # # #
# Use '%player%' for the player who sent the request.
# Use '%accept%' for the 'Click-to-accept' message.
# Use '%deny%' for the 'Click-to-deny' message.
# Use '%target%' for the player who they wanted to teleport to, and for the 'Player-sent-request' message.
# Example: /tpa <player>, where <player> is '%target%'.
Player-only-command: '&cOnly players can use this command!'
Insufficient-permission: '&cYou do not have sufficient permission!'
Player-deny-tpa-message: '&cTeleportation request has been denied.'
Target-deny-tpa-message: '&cTeleportation request has been denied.'
Target-teleportion-canceled: '&cTeleportation canceled...'
Player-got-accepted-tpa: '&bTeleportation request has been accepted.'
Countdown-until-tpa: '&eTeleporting in 3 seconds...'
Player-no-pendingtpa-message: '&cYou do not have a pending request!'
Target-accepted-tpa-request: '&eRequest for teleportation is accepted.'
Target-is-offline: '&cThis player is offline!'
No-player-found: '&cThis player does not exist!'
Player-teleporting-self: '&cYou can not teleport yourself!'
Player-already-requested: '&cYou already requested, please wait..'
Player-teleportation-request-expire: '&cTeleportation request has expired.'
Target-teleportation-request-expire: '&cTeleportation request has expired.'
Player-currently-teleporting: '&bTeleporting...'
Target-currently-teleporting: '&eTeleporting...'
Player-TpToggle-Off: '&eTeleportation &6OFF'
Player-TpToggle-On: '&eTeleportation &6ON'
Target-Is-TpToggled: '&6%target% &ehas teleportation off'
Player-Is-TpToggled: '&cYou are tptoggled!'
TpToggle-While-Teleporting: '&cCannot TpToggle while teleporting!'
Tpacancel-message: '&6Tpa request has been canceled.'
# TPA request expires in seconds
Request-expire-time: 120
# Seconds until tpa
# Please use whole numbers
Seconds-until-tpa: 3
# Becareful in this part!
# This is when a player uses not enough args
# For example, when a player does '/tpa', it will say 'Usage: /tpa <player>'
# So please fit the correct command under the correct message!
# P.S '/tpohere' is also '/s' (essentials-type command).
Tpa-usage: '&cUse: /tpa <player>'
Tpahere-usage: '&cUse: /tpahere <player>'
Tpaccept-usage: '&cUse: /tpaccept <player>'
Tpdeny-usage: '&cUse: /tpadeny <player>'
Tpo-usage: '&cUse: /tpo <player>'
Tpohere-usage: '&cUse: /tpohere <player> or /s <player>'
# # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Please Read! #
# #
# # # # # # # # # # # # # # # # # # # # # # # # #
# This section is when a player gets a tpa request
# Since the code used is broken into many parts, there will be many messages.
# Whatever you do to the "Click-to-x" messages, will be the same in the 'Tpa-message'
# Be careful!
# Lets you choose if you want players to be able
# to move before being teleported
Allow-player-to-move: false
Player-moved-before-tp: '&6The request was canceled because %player% moved!'
Player-sent-request: '&eYou have sent a request to &6%target%'
Tpa-message:
- ''
- '&e%player% &6has requested to teleport to you.'
- '&6Click %accept% &6to accept or click %deny% &6to deny.'
- '&6The request expires in 120 seconds.'
- ''
Tpahere-message:
- ''
- '&e%player% &6has requested to teleport you to them.'
- '&6Click %accept% &6to accept or click %deny% &6to deny.'
- '&6The request expires in 120 seconds.'
- ''
# This will put additional spaces for the accept/deny messages
Center-accept-deny-msg: true
Click-to-accept: '&a&l&n[Accept]&r'
Click-to-deny: '&c&l&n[Deny]&r'
Hover-message-on-accept: '&aClick to accept'
Hover-message-on-deny: '&cClick to deny'
#
# On-Screen Messages
# It pops up in the middle of the player's screen
#
Send-on-screen-message: true
# When a player accepts a tp
On-screen-teleporting:
- '&6Teleporting...'
- '&eDo not move!'
# When a player has successfully tp'd.
On-screen-teleported: '&aTeleported!'
# If a player moves while they are being tp'd
On-screen-canceled-tp: '&cCanceled TP!'
#~~~~~~~~~~~~~~~~~~#
# More Coming Soon!#
#~~~~~~~~~~~~~~~~~~#
-32
View File
@@ -1,32 +0,0 @@
name: ClickTpa
version: 1.7.1
main: com.jklmao.plugin.ClickTpa
authors: [ jklmao ]
description: Simple TPA plugin for Spigot/Paper Software
commands:
tpa:
usage: /<command>
aliases: [teleport]
tpahere:
usage: /<command>
tpaccept:
usage: /<command>
aliases: [tpyes]
tpadeny:
usage: /<command>
aliases: [tpdeny, tpno]
tpo:
usage: /<command>
alises: [tp]
tpohere:
usage: /<command>
aliases: [s, tphere]
tptoggle:
usage: /<command>
tpacancel:
usage: /<command>
aliases: [tpcancel]
clicktparl:
usage: /<command>
aliases: [ctparl]
+18
View File
@@ -0,0 +1,18 @@
MIT No Attribution
Copyright (c) 2023 darksaid98
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-3
View File
@@ -1,3 +0,0 @@
ClickTpa
Author: humonga (aliases: jklmao, Chris)
Simple TP plugin that allows players to click chat to accepts TPs.
+159
View File
@@ -0,0 +1,159 @@
import java.time.Instant
plugins {
`java-library`
id("com.github.johnrengelman.shadow") version "8.1.1" // Shades and relocates dependencies, See https://imperceptiblethoughts.com/shadow/introduction/
id("xyz.jpenilla.run-paper") version "2.2.2" // Adds runServer and runMojangMappedServer tasks for testing
id("net.minecrell.plugin-yml.bukkit") version "0.6.0" // Automatic plugin.yml generation
eclipse
idea
}
group = "io.github.Alathra"
version = "1.0.0"
description = "Simple collection of commands for the Alathra server."
val mainPackage = "${project.group}.${rootProject.name}"
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(JavaVersion.VERSION_17.majorVersion)) // Configure the java toolchain. This allows gradle to auto-provision JDK 17 on systems that only have JDK 8 installed for example.
}
repositories {
mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://mvn-repo.arim.space/lesser-gpl3/")
maven("https://jitpack.io") {
content {
includeGroup("com.github.MilkBowl")
includeGroup("com.github.milkdrinkers")
}
}
maven("https://repo.codemc.org/repository/maven-public/") {
content { includeGroup("dev.jorel") }
}
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") {
content { includeGroup("me.clip") }
}
/* EssentialsX */
// maven("https://repo.essentialsx.net/releases/")
// maven("https://repo.essentialsx.net/snapshots/")
// mavenCentral {
// content { includeGroup("net.kyori") }
// }
}
dependencies {
compileOnly("org.jetbrains:annotations:24.1.0")
annotationProcessor("org.jetbrains:annotations:24.1.0")
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
implementation("space.arim.morepaperlib:morepaperlib:latest.release")
implementation("com.github.milkdrinkers:crate:1.1.0")
implementation("com.github.milkdrinkers:colorparser:2.0.0") {
exclude("net.kyori")
}
implementation("dev.jorel:commandapi-bukkit-shade:9.2.0")
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
compileOnly("me.clip:placeholderapi:2.11.5")
}
tasks {
build {
dependsOn(shadowJar)
}
compileJava {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
// See https://openjdk.java.net/jeps/247 for more information.
options.release.set(17)
options.compilerArgs.addAll(arrayListOf("-Xlint:all", "-Xlint:-processing", "-Xdiags:verbose"))
}
javadoc {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
}
processResources {
filteringCharset = Charsets.UTF_8.name() // We want UTF-8 for everything
}
shadowJar {
archiveBaseName.set(project.name)
archiveClassifier.set("")
// Shadow classes
fun reloc(originPkg: String, targetPkg: String) = relocate(originPkg, "${mainPackage}.lib.${targetPkg}")
reloc("space.arim.morepaperlib", "morepaperlib")
reloc("com.github.milkdrinkers.Crate", "crate")
reloc("com.github.milkdrinkers.colorparser", "colorparser")
reloc("dev.jorel.commandapi", "commandapi")
minimize()
}
runServer {
// Configure the Minecraft version for our task.
minecraftVersion("1.20.2")
// IntelliJ IDEA debugger setup: https://docs.papermc.io/paper/dev/debugging#using-a-remote-debugger
jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", "-DPaper.IgnoreJavaVersion=true", "-Dcom.mojang.eula.agree=true", "-DIReallyKnowWhatIAmDoingISwear")
systemProperty("terminal.jline", false)
systemProperty("terminal.ansi", true)
// Automatically install dependencies
downloadPlugins {
// modrinth("carbon", "2.1.0-beta.21")
// github("jpenilla", "MiniMOTD", "v2.0.13", "minimotd-bukkit-2.0.13.jar")
// hangar("squaremap", "1.2.0")
// url("https://download.luckperms.net/1515/bukkit/loader/LuckPerms-Bukkit-5.4.102.jar")
github("MilkBowl", "Vault", "1.7.3", "Vault.jar")
}
}
}
bukkit {
// Plugin main class (required)
main = "${mainPackage}.${rootProject.name}"
// Plugin Information
name = project.name
prefix = project.name
version = "${project.version}"
description = "${project.description}"
authors = listOf("jklmao", "darksaid98")
contributors = listOf()
apiVersion = "1.19"
website = "https://github.com/darksaid98/ClickTpa/"
// Misc properties
load = net.minecrell.pluginyml.bukkit.BukkitPluginDescription.PluginLoadOrder.POSTWORLD // STARTUP or POSTWORLD
depend = listOf()
softDepend = listOf("PlaceholderAPI", "Vault", "Essentials")
}
// Apply custom version arg
val versionArg = if (hasProperty("customVersion"))
(properties["customVersion"] as String).uppercase() // Uppercase version string
else
"${project.version}-SNAPSHOT-${Instant.now().epochSecond}" // Append snapshot to version
// Strip prefixed "v" from version tag
project.version = if (versionArg.first().equals('v', true))
versionArg.substring(1)
else
versionArg.uppercase()
+4
View File
@@ -0,0 +1,4 @@
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048M
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+249
View File
@@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+92
View File
@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+12
View File
@@ -0,0 +1,12 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
}
rootProject.name = "AlathranCommands"
@@ -0,0 +1,71 @@
package io.github.Alathra.AlathranCommands;
import com.github.milkdrinkers.colorparser.ColorParser;
import io.github.Alathra.AlathranCommands.commands.CommandHandler;
import io.github.Alathra.AlathranCommands.hooks.VaultHook;
import io.github.Alathra.AlathranCommands.listener.ListenerHandler;
import io.github.Alathra.AlathranCommands.utils.Logger;
import io.github.Alathra.AlathranCommands.config.TeleportConfigHandler;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
public final class AlathranCommands extends JavaPlugin {
private static AlathranCommands instance;
private TeleportConfigHandler teleportConfigHandler;
private CommandHandler commandHandler;
private ListenerHandler listenerHandler;
private static VaultHook vaultHook;
public static AlathranCommands getInstance() {
return instance;
}
@Override
public void onLoad() {
instance = this;
teleportConfigHandler = new TeleportConfigHandler(instance);
commandHandler = new CommandHandler(instance);
listenerHandler = new ListenerHandler(instance);
vaultHook = new VaultHook(instance);
teleportConfigHandler.onLoad();
commandHandler.onLoad();
listenerHandler.onLoad();
vaultHook.onLoad();
}
@Override
public void onEnable() {
saveDefaultConfig();
teleportConfigHandler.onEnable();
commandHandler.onEnable();
listenerHandler.onEnable();
vaultHook.onEnable();
// Economy Notification
if (vaultHook.isVaultLoaded()) {
Logger.get().info(ColorParser.of("<green>Vault has been found on this server. Economy support enabled.").build());
} else {
Logger.get().warn(ColorParser.of("<yellow>Vault is not installed on this server. Economy support has been disabled.").build());
}
Logger.get().info(ColorParser.of("<green>AlathranCommands successfully loaded.").build());
}
@Override
public void onDisable() {
commandHandler.onDisable();
listenerHandler.onDisable();
vaultHook.onDisable();
teleportConfigHandler.onDisable();
}
@NotNull
public TeleportConfigHandler getTeleportConfigHandler() {
return teleportConfigHandler;
}
public static VaultHook getVaultHook() {
return vaultHook;
}
}
@@ -0,0 +1,21 @@
package io.github.Alathra.AlathranCommands;
/**
* Implemented in classes that should support being reloaded IE executing the methods during runtime after startup.
*/
public interface Reloadable {
/**
* On getInstance load.
*/
void onLoad();
/**
* On getInstance enable.
*/
void onEnable();
/**
* On getInstance disable.
*/
void onDisable();
}
@@ -0,0 +1,42 @@
package io.github.Alathra.AlathranCommands.commands;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import com.github.milkdrinkers.colorparser.ColorParser;
import io.github.Alathra.AlathranCommands.utils.ConfigUtil;
import org.jetbrains.annotations.Nullable;
public class CommandAlathra implements ConfigUtil {
final private String prefix = "[ACMDS]";
private final AlathranCommands alathraCommands;
CommandAlathra(AlathranCommands pl) {
alathraCommands = pl;
alathraCommands.saveDefaultConfig();
new CommandAPICommand("alathracommands")
.withSubcommands(
new CommandAPICommand("reload")
.withPermission(CommandPermission.fromString("alathrancommands.reload"))
.executes((sender, args) -> {
alathraCommands.saveDefaultConfig();
alathraCommands.reloadConfig();
sender.sendMessage(ColorParser.of(prefix + " <green>config has been reloaded!").build());
})/*, // TODO Re-enable when implementation is finished
new CommandAPICommand("schedule")
.withPermission(CommandPermission.fromString("alathrancommands.schedule"))
.withSubcommands(
CommandStop.registerStopCommand(),
CommandStop.registerRestartCommand(),
CommandStop.registerCancelCommand()
)*/
)
.register();
}
public @Nullable String getMsg(String path) {
return alathraCommands.getConfig().getString(path);
}
}
@@ -0,0 +1,43 @@
package io.github.Alathra.AlathranCommands.commands;
import dev.jorel.commandapi.CommandAPI;
import dev.jorel.commandapi.CommandAPIBukkitConfig;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import io.github.Alathra.AlathranCommands.Reloadable;
/**
* A class to handle registration of commands.
*/
public class CommandHandler implements Reloadable {
private final AlathranCommands instance;
public CommandHandler(AlathranCommands instance) {
this.instance = instance;
}
@Override
public void onLoad() {
CommandAPI.onLoad(new CommandAPIBukkitConfig(instance).shouldHookPaperReload(true).silentLogs(true));
}
@Override
public void onEnable() {
CommandAPI.onEnable();
// Register commands here
new CommandAlathra(instance);
new CommandTpa(instance);
new CommandTpaHere(instance);
new CommandTpCancel(instance);
new CommandTpaccept(instance);
new CommandTpaDeny(instance);
new CommandTpo(instance);
new CommandTpoHere(instance);
new CommandTpToggle(instance);
}
@Override
public void onDisable() {
CommandAPI.onDisable();
}
}
@@ -0,0 +1,152 @@
package io.github.Alathra.AlathranCommands.commands;
import com.github.milkdrinkers.colorparser.ColorParser;
import dev.jorel.commandapi.CommandAPIBukkit;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.ArgumentSuggestions;
import dev.jorel.commandapi.arguments.IntegerArgument;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import org.bukkit.Bukkit;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
public class CommandStop {
private enum ActionType {
STOP,
RESTART
}
public static CommandAPICommand registerStopCommand() {
return new CommandAPICommand("stop")
.withPermission(CommandPermission.fromString("alathrancommands.stop"))
.withArguments(
List.of(
new IntegerArgument("time")
.replaceSuggestions(
ArgumentSuggestions.strings(
List.of(
"0",
"5",
"10",
"15",
"60"
)
)
)
)
)
.executes((s, args) -> {
if (isActionScheduled)
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("").build());
final int minutes = (int) args.getOrDefault("time", 5);
actionType = ActionType.STOP;
acitonDuration = Duration.ofMinutes(minutes);
actionBeginTime = Instant.now();
actionEndTime = Instant.now().plus(acitonDuration);
scheduleStart();
});
}
public static CommandAPICommand registerRestartCommand() {
return new CommandAPICommand("restart")
.withPermission(CommandPermission.fromString("alathrancommands.restart"))
.withArguments(
List.of(
new IntegerArgument("time")
.replaceSuggestions(
ArgumentSuggestions.strings(
List.of(
"0",
"5",
"10",
"15",
"60"
)
)
)
)
)
.executes((s, args) -> {
if (isActionScheduled)
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("").build());
final int minutes = (int) args.getOrDefault("time", 5);
actionType = ActionType.RESTART;
acitonDuration = Duration.ofMinutes(minutes);
actionBeginTime = Instant.now();
actionEndTime = Instant.now().plus(acitonDuration);
scheduleStart();
});
}
public static CommandAPICommand registerCancelCommand() {
return new CommandAPICommand("cancel")
.withPermission(CommandPermission.fromString("alathrancommands.cancel"))
.executes((s, args) -> {
if (!isActionScheduled)
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("").build());
s.sendMessage(ColorParser.of("Cancelled").build());
scheduleStop();
});
}
private static boolean isActionScheduled = false;
private static ActionType actionType;
private static int actionTaskId = 0;
private static Duration acitonDuration = Duration.ZERO;
private static Instant actionBeginTime = Instant.EPOCH;
private static Instant actionEndTime = Instant.EPOCH;
private static void scheduleStop() {
Bukkit.getScheduler().cancelTask(actionTaskId);
actionType = ActionType.RESTART;
actionTaskId = 0;
acitonDuration = Duration.ZERO;
actionBeginTime = Instant.EPOCH;
actionEndTime = Instant.EPOCH;
isActionScheduled = false;
}
private static void scheduleStart() {
isActionScheduled = true;
actionTaskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(AlathranCommands.getInstance(), () -> {
final Instant currentTime = Instant.now();
final Duration remainingTime = Duration.between(currentTime, actionBeginTime);
final boolean shouldStop = currentTime.isAfter(actionEndTime) && !Bukkit.isStopping();
if (shouldStop) {
Bukkit.broadcast(ColorParser.of("&a[&cScheduler&a] Stopping the server...").build());
Bukkit.shutdown();
return;
}
// Announce minutes remaining
if (remainingTime.toSecondsPart() == 0) {
switch (Math.toIntExact(remainingTime.toMinutes())) {
case 30, 10, 5, 4, 3, 2, 1 -> {
Bukkit.broadcast(ColorParser.of("&a[&cScheduler&a] Stopping the server in <time> minutes.").build());
return;
}
}
}
// Announce seconds remaining
if (remainingTime.toMinutes() == 0) {
switch (Math.toIntExact(remainingTime.toSeconds())) {
case 30, 20, 10, 5, 4, 3, 2, 1 -> {
Bukkit.broadcast(ColorParser.of("&a[&cScheduler&a] Stopping the server in <time> seconds.").build());
return;
}
}
}
}, 0L, 20L);
}
}
@@ -0,0 +1,81 @@
package io.github.Alathra.AlathranCommands.commands;
import com.github.milkdrinkers.colorparser.ColorParser;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import dev.jorel.commandapi.CommandAPIBukkit;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.PlayerArgument;
import dev.jorel.commandapi.executors.CommandArguments;
import io.github.Alathra.AlathranCommands.data.PlayerManager;
import io.github.Alathra.AlathranCommands.data.model.TPARequest;
import io.github.Alathra.AlathranCommands.utils.TPCfg;
import org.bukkit.entity.Player;
public class CommandTpCancel {
private final AlathranCommands alathraCommands;
public CommandTpCancel(AlathranCommands pl) {
alathraCommands = pl;
new CommandAPICommand("tpacancel")
.withAliases("etpacancel", "tpcancel")
.withPermission(CommandPermission.fromString("alathrancommands.tpacancel"))
.withOptionalArguments(new PlayerArgument("target"))
.executesPlayer((Player p, CommandArguments args) -> {
if (PlayerManager.getInstance().getPlayer(p).getOutgoingTPARequests().isEmpty()) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outgoing-request")).build());
}
// Get optionally specified target
Player target;
if (args.get("target") != null) {
target = (Player) args.get("target");
} else if (PlayerManager.getInstance().getPlayer(p).getNextTpaRequest(false, false) != null) {
target = PlayerManager.getInstance().getPlayer(p).getNextTpaRequest(false, false).getTarget();
} else {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outstanding-request")).build());
}
if (target == null || !target.isOnline()) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-target-offline")).build());
}
if (!PlayerManager.getInstance().getPlayer(p).getOutgoingTPARequests().contains(target.getUniqueId())) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outgoing-request")).build());
}
if (p == target) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-istarget")).build());
}
/*if (!PlayerManager.getInstance().getPlayer(p).isOutgoingTPARequest()) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outstanding-request")).build());
}
Player target = Bukkit.getServer().getPlayer(alathraCommands.getTpaCancel().get(p).getName());
Player target = Bukkit.getServer().getPlayer(PlayerManager.getInstance().getPlayer(p).getOutgoingTPARequests().);*/
/*if (target == null) {
alathraCommands.getTpaCancel().remove(p);
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.request-canceled-origin")).parseMinimessagePlaceholder("target", alathraCommands.getTpaCancel().get(p).getName()).build());
}*/
//removeTpaInfo(p, target);
TPARequest request = PlayerManager.getInstance().getPlayer(target).getOutstandingTpaRequest(p, false);
if (request == null || request.isProcessed()) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outstanding-request")).build());
}
request.setProcessed(true);
target.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.request-canceled-target")).parseMinimessagePlaceholder("origin", p.getName()).build());
p.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.request-canceled-origin")).parseMinimessagePlaceholder("target", target.getName()).build());
PlayerManager.getInstance().getPlayer(request.getTarget()).removeTPARequest(request.getOrigin());
PlayerManager.getInstance().getPlayer(request.getOrigin()).removeOutgoingTPARequest(request.getTarget());
//removeTpaInfo(p, target);
})
.register();
}
}
@@ -0,0 +1,40 @@
package io.github.Alathra.AlathranCommands.commands;
import com.github.milkdrinkers.colorparser.ColorParser;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import io.github.Alathra.AlathranCommands.data.PlayerManager;
import io.github.Alathra.AlathranCommands.enums.TeleportMode;
import io.github.Alathra.AlathranCommands.utils.TPCfg;
public class CommandTpToggle {
private final AlathranCommands alathraCommands;
public CommandTpToggle(AlathranCommands pl) {
alathraCommands = pl;
new CommandAPICommand("tptoggle")
.withAliases("etptoggle")
.withPermission(CommandPermission.fromString("alathrancommands.tptoggle"))
.executesPlayer((p, args) -> {
TeleportMode mode = PlayerManager.getInstance().getPlayer(p).getTeleportMode();
switch (mode) {
case DEFAULT -> { // turn on tptoggle
PlayerManager.getInstance().getPlayer(p).setTeleportMode(TeleportMode.TPTOGGLE_ON);
p.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.tptoggle-on")).build());
}
case TPTOGGLE_ON -> {
PlayerManager.getInstance().getPlayer(p).setTeleportMode(TeleportMode.DEFAULT);
p.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.tptoggle-off")).build());
}
case TELEPORTING ->
p.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.tptoggle-busy")).build());
default -> {
}
}
})
.register();
}
}
@@ -0,0 +1,51 @@
package io.github.Alathra.AlathranCommands.commands;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import dev.jorel.commandapi.CommandAPIBukkit;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.PlayerArgument;
import dev.jorel.commandapi.executors.CommandArguments;
import io.github.Alathra.AlathranCommands.data.PlayerManager;
import io.github.Alathra.AlathranCommands.data.model.TPARequest;
import io.github.Alathra.AlathranCommands.enums.TeleportMode;
import io.github.Alathra.AlathranCommands.enums.TeleportType;
import com.github.milkdrinkers.colorparser.ColorParser;
import io.github.Alathra.AlathranCommands.utils.TPCfg;
import io.github.Alathra.AlathranCommands.utils.TeleportMessage;
import org.bukkit.entity.Player;
public class CommandTpa {
public CommandTpa(AlathranCommands pl) {
new CommandAPICommand("tpa")
.withAliases("tpask")
.withPermission(CommandPermission.fromString("alathrancommands.tpa"))
.withArguments(new PlayerArgument("target"))
.executesPlayer((Player p, CommandArguments args) -> {
Player target = (Player) args.get("target");
if (p == target) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-istarget")).build());
}
if (PlayerManager.getInstance().getPlayer(target).getTeleportMode() == TeleportMode.TPTOGGLE_ON) { // TODO Accepts requests
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-target-toggled-off")).parseMinimessagePlaceholder("target", target.getName()).build());
}
// Check if currently teleporting
if (!PlayerManager.getInstance().getPlayer(p).isBusy()) {
// Already has outgoing request
if (PlayerManager.getInstance().getPlayer(p).getOutgoingTPARequests().contains(target.getUniqueId())) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-outstanding-request")).build());
}
// Add incoming and outgoing request to users
TPARequest tpaRequest = PlayerManager.getInstance().getPlayer(target).addTPARequest(p, target, TeleportType.TPA);
PlayerManager.getInstance().getPlayer(p).addOutgoingTPARequest(target);
TeleportMessage.requestSend(tpaRequest);
}
})
.register();
}
}
@@ -0,0 +1,68 @@
package io.github.Alathra.AlathranCommands.commands;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import dev.jorel.commandapi.CommandAPIBukkit;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.PlayerArgument;
import dev.jorel.commandapi.executors.CommandArguments;
import io.github.Alathra.AlathranCommands.data.PlayerManager;
import io.github.Alathra.AlathranCommands.data.model.TPARequest;
import com.github.milkdrinkers.colorparser.ColorParser;
import io.github.Alathra.AlathranCommands.utils.TPCfg;
import org.bukkit.entity.Player;
public class CommandTpaDeny {
private final AlathranCommands alathraCommands;
public CommandTpaDeny(AlathranCommands pl) {
alathraCommands = pl;
new CommandAPICommand("tpadeny")
.withAliases("tpdeny", "etpdeny", "tpno", "etpno")
.withPermission(CommandPermission.fromString("alathrancommands.tpadeny"))
.withOptionalArguments(new PlayerArgument("target"))
.executesPlayer((Player p, CommandArguments args) -> {
// Get optionally specified target
Player target;
if (args.get("target") != null) {
target = (Player) args.get("target");
} else if (PlayerManager.getInstance().getPlayer(p).getNextTpaRequest(false, false) != null) {
target = PlayerManager.getInstance().getPlayer(p).getNextTpaRequest(false, false).getTarget();
} else {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outstanding-request")).build());
}
if (target == null || !target.isOnline()) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-target-offline")).build());
}
if (p == target) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-istarget")).build());
}
if (!PlayerManager.getInstance().getPlayer(p).hasPendingTpaRequest(target)) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outstanding-request")).build());
}
TPARequest request = PlayerManager.getInstance().getPlayer(p).getOutstandingTpaRequest(target, false);
if (request == null || request.isProcessed()) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outstanding-request")).build());
}
// if (hasRequester) {
request.setProcessed(true);
p.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.request-denied-origin")).parseMinimessagePlaceholder("target", p.getName()).build());
target.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.request-denied-target")).build());
PlayerManager.getInstance().getPlayer(p).removeTPARequest(target);
PlayerManager.getInstance().getPlayer(target).removeOutgoingTPARequest(p);
//alathraCommands.getTpaCancel().remove(target);
// } else {
// throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outstanding-request")).build());
// }
})
.register();
}
}
@@ -0,0 +1,51 @@
package io.github.Alathra.AlathranCommands.commands;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import dev.jorel.commandapi.CommandAPIBukkit;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.PlayerArgument;
import dev.jorel.commandapi.executors.CommandArguments;
import io.github.Alathra.AlathranCommands.data.PlayerManager;
import io.github.Alathra.AlathranCommands.data.model.TPARequest;
import io.github.Alathra.AlathranCommands.enums.TeleportMode;
import io.github.Alathra.AlathranCommands.enums.TeleportType;
import com.github.milkdrinkers.colorparser.ColorParser;
import io.github.Alathra.AlathranCommands.config.TeleportConfigHandler;
import io.github.Alathra.AlathranCommands.utils.TPCfg;
import io.github.Alathra.AlathranCommands.utils.TeleportMessage;
import org.bukkit.entity.Player;
public class CommandTpaHere {
public CommandTpaHere(AlathranCommands pl) {
new CommandAPICommand("tpahere")
.withAliases("etpahere")
.withPermission(CommandPermission.fromString("alathrancommands.tpahere"))
.withArguments(new PlayerArgument("target"))
.executesPlayer((Player p, CommandArguments args) -> {
Player target = (Player) args.get("target");
if (p == target) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-istarget")).build());
}
if (PlayerManager.getInstance().getPlayer(target).getTeleportMode() == TeleportMode.TPTOGGLE_ON) { // TODO Accepts requests
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-target-toggled-off")).parseMinimessagePlaceholder("target", target.getName()).build());
}
// Check if currently teleporting
if (!PlayerManager.getInstance().getPlayer(p).isBusy()) {
// Already has outgoing request
if (PlayerManager.getInstance().getPlayer(p).getOutgoingTPARequests().contains(target.getUniqueId())) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-outstanding-request")).build());
}
// Add incoming and outgoing request to users
TPARequest tpaRequest = PlayerManager.getInstance().getPlayer(target).addTPARequest(p, target, TeleportType.TPAHERE);
PlayerManager.getInstance().getPlayer(p).addOutgoingTPARequest(target);
TeleportMessage.requestSend(tpaRequest);
}
})
.register();
}
}
@@ -0,0 +1,144 @@
package io.github.Alathra.AlathranCommands.commands;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import dev.jorel.commandapi.CommandAPIBukkit;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.PlayerArgument;
import dev.jorel.commandapi.executors.CommandArguments;
import io.github.Alathra.AlathranCommands.data.PlayerManager;
import io.github.Alathra.AlathranCommands.data.model.TPARequest;
import io.github.Alathra.AlathranCommands.runnable.TeleportGraceTask;
import com.github.milkdrinkers.colorparser.ColorParser;
import io.github.Alathra.AlathranCommands.utils.TPCfg;
import io.github.Alathra.AlathranCommands.utils.TeleportUtils;
import org.bukkit.entity.Player;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
public class CommandTpaccept {
private final AlathranCommands alathraCommands;
public CommandTpaccept(AlathranCommands pl) {
alathraCommands = pl;
final int seconds = alathraCommands.getConfig().getInt("Seconds-until-tpa");
new CommandAPICommand("tpaccept")
.withAliases("etpaccept", "tpyes", "etpyes")
.withPermission(CommandPermission.fromString("alathrancommands.tpaccept"))
.withOptionalArguments(new PlayerArgument("target"))
.executesPlayer((Player p, CommandArguments args) -> {
// Get optionally specified target
Player target;
if (args.get("target") != null) {
target = (Player) args.get("target");
} else if (PlayerManager.getInstance().getPlayer(p).getNextTpaRequest(false, false) != null) {
target = PlayerManager.getInstance().getPlayer(p).getNextTpaRequest(false, false).getTarget(); // This returns the wrong us
} else {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outstanding-request")).build());
}
if (target == null || !target.isOnline()) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-target-offline")).build());
}
if (p == target) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-istarget")).build());
}
if (!PlayerManager.getInstance().getPlayer(p).hasPendingTpaRequest(target)) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outstanding-request")).build());
}
TPARequest request = PlayerManager.getInstance().getPlayer(p).getOutstandingTpaRequest(target, false);
if (request == null || request.isProcessed()) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-no-outstanding-request")).build());
}
switch (request.getType()) {
case TPA -> {
if (PlayerManager.getInstance().getPlayer(request.getOrigin()).isBusy()) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.request-canceled-isbusy")).build());
}
}
case TPAHERE -> {
if (PlayerManager.getInstance().getPlayer(request.getTarget()).isBusy()) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.request-canceled-isbusy")).build());
}
}
}
switch (request.getType()) {
case TPA, TPAHERE -> {
request.getOrigin().sendMessage(ColorParser.of(TPCfg.get().getString("Messages.request-accepted-origin")).parseMinimessagePlaceholder("target", request.getTarget().getName()).build());
request.getTarget().sendMessage(ColorParser.of(TPCfg.get().getString("Messages.request-accepted-target")).parseMinimessagePlaceholder("origin", request.getOrigin().getName()).build());
}
}
final CompletableFuture<Boolean> future = new CompletableFuture<>();
// Remove requests
future.whenComplete((_result, _throwable) -> {
switch (request.getType()) {
case TPA -> {
if (PlayerManager.getInstance().getPlayer(request.getOrigin()) != null) {
PlayerManager.getInstance().getPlayer(request.getOrigin()).setBusy(false);
};
// If a players data is missing it has already been cleaned up by logout logic
if (PlayerManager.getInstance().getPlayer(request.getOrigin()) == null || PlayerManager.getInstance().getPlayer(request.getTarget()) == null) break;
PlayerManager.getInstance().getPlayer(request.getTarget()).removeTPARequest(request.getTarget());
PlayerManager.getInstance().getPlayer(request.getOrigin()).removeOutgoingTPARequest(request.getTarget());
}
case TPAHERE -> {
if (PlayerManager.getInstance().getPlayer(request.getTarget()) != null) {
PlayerManager.getInstance().getPlayer(request.getTarget()).setBusy(false);
};
// If a players data is missing it has already been cleaned up by logout logic
if (PlayerManager.getInstance().getPlayer(request.getOrigin()) == null || PlayerManager.getInstance().getPlayer(request.getTarget()) == null) break;
PlayerManager.getInstance().getPlayer(request.getTarget()).removeTPARequest(request.getOrigin());
PlayerManager.getInstance().getPlayer(request.getOrigin()).removeOutgoingTPARequest(request.getTarget());
}
}
});
request.setProcessed(true);
final long grace = Duration.ofSeconds(TPCfg.get().getInt("Settings.TPA.Grace.Time")).toMillis();
if (grace == 0) {
TeleportUtils.asyncTeleport(request, future);
} else {
new TeleportGraceTask(request, grace, future);
}
switch (request.getType()) {
case TPA -> {
PlayerManager.getInstance().getPlayer(request.getOrigin()).setBusy(true);
//target.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.request-grace-begin-origin")).parseMinimessagePlaceholder("time", seconds).build());
/*alathraCommands.getTpaPlayers().get(target).setMode(TeleportMode.TELEPORTING);
alathraCommands.getGraceList().add(target);
cdListener.tpaCountdown(seconds, TeleportType.TPA, p, target);*/
}
case TPAHERE -> {
PlayerManager.getInstance().getPlayer(request.getTarget()).setBusy(true);
//p.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.request-grace-begin-origin")).parseMinimessagePlaceholder("time", seconds).build());
/*alathraCommands.getTpaPlayers().get(p).setMode(TeleportMode.TELEPORTING);
alathraCommands.getGraceList().add(p);
cdListener.tpaCountdown(seconds, TeleportType.TPAHERE, p, target);*/
}
}
//alathraCommands.getTpaCancel().remove(target);
})
.register();
}
}
@@ -0,0 +1,44 @@
package io.github.Alathra.AlathranCommands.commands;
import com.github.milkdrinkers.colorparser.ColorParser;
import dev.jorel.commandapi.CommandAPIBukkit;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.PlayerArgument;
import dev.jorel.commandapi.executors.CommandArguments;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import io.github.Alathra.AlathranCommands.utils.ConfigUtil;
import io.github.Alathra.AlathranCommands.utils.TPCfg;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.jetbrains.annotations.Nullable;
public class CommandTpo implements ConfigUtil {
private final AlathranCommands alathraCommands;
public CommandTpo(AlathranCommands pl) {
alathraCommands = pl;
new CommandAPICommand("tpo")
.withAliases("tp")
.withPermission(CommandPermission.fromString("alathrancommands.tpo"))
.withArguments(new PlayerArgument("target"))
.executesPlayer((Player p, CommandArguments args) -> {
Player target = (Player) args.get("target");
if (p == target) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-istarget")).build());
}
p.sendMessage(ColorParser.of(getMsg("Player-currently-teleporting")).build());
target.sendMessage(ColorParser.of(getMsg("Target-currently-teleporting")).build());
p.teleportAsync(target.getLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
})
.register();
}
@Override
public @Nullable String getMsg(String path) {
return alathraCommands.getConfig().getString(path);
}
}
@@ -0,0 +1,44 @@
package io.github.Alathra.AlathranCommands.commands;
import com.github.milkdrinkers.colorparser.ColorParser;
import dev.jorel.commandapi.CommandAPIBukkit;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.PlayerArgument;
import dev.jorel.commandapi.executors.CommandArguments;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import io.github.Alathra.AlathranCommands.utils.ConfigUtil;
import io.github.Alathra.AlathranCommands.utils.TPCfg;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.jetbrains.annotations.Nullable;
public class CommandTpoHere implements ConfigUtil {
private final AlathranCommands alathraCommands;
public CommandTpoHere(AlathranCommands pl) {
alathraCommands = pl;
new CommandAPICommand("tpohere")
.withAliases("etpohere", "tphere")
.withPermission(CommandPermission.fromString("alathrancommands.tpohere"))
.withArguments(new PlayerArgument("target"))
.executesPlayer((Player p, CommandArguments args) -> {
Player target = (Player) args.get("target");
if (p == target) {
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(TPCfg.get().getString("Messages.error-origin-istarget")).build());
}
p.sendMessage(ColorParser.of(getMsg("Player-currently-teleporting")).build());
target.teleportAsync(p.getLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
target.sendMessage(ColorParser.of(getMsg("Target-currently-teleporting")).build());
})
.register();
}
@Override
public @Nullable String getMsg(String path) {
return alathraCommands.getConfig().getString(path);
}
}
@@ -0,0 +1,17 @@
package io.github.Alathra.AlathranCommands.commands.interfaces;
import org.bukkit.command.CommandSender;
import java.util.concurrent.CompletableFuture;
public class Command {
public CompletableFuture<Boolean> getNewExceptionFuture(final CommandSender sender, final String commandLabel) {
final CompletableFuture<Boolean> future = new CompletableFuture<>();
future.exceptionally(e -> {
e.printStackTrace();
//showError(sender.getSender(), e, commandLabel);
return false;
});
return future;
}
}
@@ -0,0 +1,36 @@
package io.github.Alathra.AlathranCommands.config;
import com.github.milkdrinkers.Crate.Config;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import io.github.Alathra.AlathranCommands.Reloadable;
public class TeleportConfigHandler implements Reloadable {
private final AlathranCommands instance;
private static Config cfg;
public TeleportConfigHandler(AlathranCommands instance) {
this.instance = instance;
}
@Override
public void onLoad() {
cfg = new Config("teleport", instance.getDataFolder().getPath(), instance.getResource("teleport.yml")); // Create a config file from the template in our resources folder
}
@Override
public void onEnable() {
}
@Override
public void onDisable() {
}
/**
* Gets AlathranCommands Teleport config object.
*
* @return the Teleport config object
*/
public Config getConfig() {
return cfg;
}
}
@@ -0,0 +1,51 @@
package io.github.Alathra.AlathranCommands.data;
import io.github.Alathra.AlathranCommands.data.model.PlayerData;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* Singleton to store and access player data
*/
public class PlayerManager {
private static PlayerManager instance;
@NotNull
public static PlayerManager getInstance() {
if (instance == null) instance = new PlayerManager();
return instance;
}
private final Map<UUID, PlayerData> playerDataMap = new HashMap<>();
@Nullable
public PlayerData getPlayer(UUID uuid) {
return playerDataMap.get(uuid);
}
@Nullable
public PlayerData getPlayer(Player p) {
return getPlayer(p.getUniqueId());
}
public void setPlayer(UUID uuid, PlayerData playerData) {
playerDataMap.put(uuid, playerData);
}
public void setPlayer(Player p, PlayerData playerData) {
setPlayer(p.getUniqueId(), playerData);
}
public void removePlayer(UUID uuid) {
playerDataMap.remove(uuid);
}
public void removePlayer(Player p) {
removePlayer(p.getUniqueId());
}
}
@@ -0,0 +1,198 @@
package io.github.Alathra.AlathranCommands.data.model;
import io.github.Alathra.AlathranCommands.enums.TeleportMode;
import io.github.Alathra.AlathranCommands.enums.TeleportType;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.*;
public class PlayerData {
private final transient LinkedHashMap<UUID, TPARequest> teleportRequestQueue = new LinkedHashMap<>(); // Store requests by target UUID
private final transient LinkedList<UUID> outgoingTPARequests = new LinkedList<>(); // Store UUID of targets
private TeleportMode teleportMode = TeleportMode.DEFAULT;
private boolean busy = false;
public boolean isBusy() {
return busy;
}
public void setBusy(boolean busy) {
this.busy = busy;
}
public boolean hasTPARequestFrom(final UUID uuid) {
return teleportRequestQueue.containsKey(uuid);
}
public boolean hasTPARequestFrom(final Player p) {
return hasTPARequestFrom(p.getUniqueId());
}
/**
* Add a teleport request
*
* @param origin The player that is teleported
* @param target The player being teleported to
* @param type Teleport type
*
* @apiNote Use `type` to determine who is the tp requester
*/
public TPARequest addTPARequest(final Player origin, final Player target, final TeleportType type) {
final TPARequest request = new TPARequest(origin, target, type);
// Handle max queue size
teleportRequestQueue.remove(request.getOrigin().getUniqueId());
if (teleportRequestQueue.size() >= 10) {
final List<UUID> keys = new ArrayList<>(teleportRequestQueue.keySet());
teleportRequestQueue.remove(keys.get(keys.size() - 1));
}
// Add request to queue
teleportRequestQueue.put(request.getOrigin().getUniqueId(), request);
return request;
}
/**
* Remove request from the specified UUID
*
* @param uuid uuid
*
* @return removed request
*/
public TPARequest removeTPARequest(final UUID uuid) {
return teleportRequestQueue.remove(uuid);
}
public TPARequest removeTPARequest(final Player p) {
return removeTPARequest(p.getUniqueId());
}
/**
* Check if player has any pending tpa requests
*
* @param notify boolean, should we send a message to inform player of timed out request
*
* @return boolean
*/
public boolean hasPendingTpaRequests(final boolean notify) {
return getNextTpaRequest(notify, false) != null;
}
/**
* Check if player has a pending tpa request
*
* @param uuid uuid
*
* @return boolean
*/
public boolean hasPendingTpaRequest(final UUID uuid) {
final TPARequest request = getOutstandingTpaRequest(uuid, false);
return request != null;
}
public boolean hasPendingTpaRequest(final Player p) {
return hasPendingTpaRequest(p.getUniqueId());
}
/**
* Returns null if request doesn't exist or is timed out
*
* @param uuid uuid
* @param notify boolean, should we send a message to inform player of timed out request
*
* @return request or null
*/
public @Nullable TPARequest getOutstandingTpaRequest(final UUID uuid, final boolean notify) {
if (!teleportRequestQueue.containsKey(uuid)) {
return null;
}
final TPARequest request = teleportRequestQueue.get(uuid);
if (!request.isExpired()) {
return request;
}
removeTPARequest(uuid);
if (notify) {
final Player p = Bukkit.getPlayer(uuid);
p.sendMessage("Request timed out %s"); // TODO send msg TeleportConfigHandler requestTimedOutFrom
}
return null;
}
public @Nullable TPARequest getOutstandingTpaRequest(final Player p, final boolean notify) {
return getOutstandingTpaRequest(p.getUniqueId(), notify);
}
/**
* Loop through requests from oldest to newest to find the most recent valid request
*
* @param notify boolean, should we send a message to inform player of timed out request
* @param ignoreExpirations boolean, will return no longer valid requests
*
* @return request or null
*/
public @Nullable TPARequest getNextTpaRequest(final boolean notify, final boolean ignoreExpirations) {
if (teleportRequestQueue.isEmpty()) return null;
final List<UUID> keys = new ArrayList<>(teleportRequestQueue.keySet());
Collections.reverse(keys);
TPARequest nextRequest = null;
for (final UUID uuid : keys) {
final TPARequest request = teleportRequestQueue.get(uuid);
if (!request.isExpired()) {
if (ignoreExpirations) {
return request;
} else if (nextRequest == null) {
nextRequest = request;
}
} else {
if (notify) {
final Player p = Bukkit.getPlayer(uuid);
p.sendMessage("Request timed out %s"); // TODO send msg TeleportConfigHandler requestTimedOutFrom
//sendMessage(tl("requestTimedOutFrom", ess.getUser(request.getRequesterUuid()).getDisplayName()));
}
removeTPARequest(uuid);
}
}
return nextRequest;
}
public LinkedList<UUID> getOutgoingTPARequests() {
return outgoingTPARequests;
}
public void addOutgoingTPARequest(UUID uuid) {
outgoingTPARequests.add(uuid);
}
public void addOutgoingTPARequest(Player p) {
addOutgoingTPARequest(p.getUniqueId());
}
public void removeOutgoingTPARequest(UUID uuid) {
outgoingTPARequests.remove(uuid);
}
public void removeOutgoingTPARequest(Player p) {
removeOutgoingTPARequest(p.getUniqueId());
}
public TeleportMode getTeleportMode() {
return teleportMode;
}
public void setTeleportMode(TeleportMode mode) {
teleportMode = mode;
}
}
@@ -0,0 +1,143 @@
package io.github.Alathra.AlathranCommands.data.model;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import io.github.Alathra.AlathranCommands.enums.TeleportType;
import io.github.Alathra.AlathranCommands.utils.TPCfg;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.concurrent.TimeUnit;
/**
* The type Tpa request.
*/
public class TPARequest {
private final long timeout;
private final Player origin; // Always the sender of the request
private final Player target; // Always the responder of the request
private final TeleportType type;
private boolean processed = false; // Has this request been processed (true when a command uses the request)
private long time;
private int price = 0;
/**
* Instantiates a new Tpa request.
*
* @param origin the origin
* @param target the target
* @param type the type
*/
public TPARequest(Player origin, Player target, TeleportType type) {
this.origin = origin;
this.target = target;
this.type = type;
this.time = System.currentTimeMillis();
this.timeout = TimeUnit.SECONDS.toMillis(TPCfg.get().getInt("Settings.TPA.Timeout"));
if (Bukkit.getServer().getPluginManager().isPluginEnabled("Vault")) {
this.price = TPCfg.get().getInt("Settings.TPA.Price");
}
}
/**
* Gets origin. Always the sender of the request.
*
* @return the origin
*/
public Player getOrigin() {
return origin;
}
/**
* Gets target. Always the responder of the request
* @return the target
*/
public Player getTarget() {
return target;
}
/**
* Gets type.
*
* @return the type
*/
public TeleportType getType() {
return type;
}
/**
* Gets time.
*
* @return the time
*/
public long getTime() {
return time;
}
/**
* Sets time.
*
* @param time the time
*/
public void setTime(long time) {
this.time = time;
}
/**
* Check if this request has expired
*
* @return boolean boolean
*/
public boolean isExpired() {
return !( timeout < 1 || ( System.currentTimeMillis() - getTime() ) <= timeout );
}
/**
* Can afford boolean.
*
* @return the boolean
*/
public boolean canAfford() {
if (AlathranCommands.getVaultHook().isVaultLoaded())
return AlathranCommands.getVaultHook().getVault().getBalance(Bukkit.getOfflinePlayer(this.getOrigin().getUniqueId())) > price;
return true;
}
/**
* Make origin pay price.
*/
public void payPrice() {
if (AlathranCommands.getVaultHook().isVaultLoaded())
AlathranCommands.getVaultHook().getVault().withdrawPlayer(this.getOrigin(), price);
}
/**
* Has cooldown boolean.
*
* @return the boolean
*/
// TODO implement cooldown system
public boolean hasCooldown() {
return true;
}
/**
* Return if this request has been processed.
*
* @return the boolean
*/
public boolean isProcessed() {
return processed;
}
/**
* Sets if this request has been processed.
*
* @param processed the processed
*/
public void setProcessed(boolean processed) {
this.processed = processed;
}
}
@@ -0,0 +1,8 @@
package io.github.Alathra.AlathranCommands.enums;
/**
* The current mode tells you what the player is currently doing
*/
public enum TeleportMode {
DEFAULT, TELEPORTING, TPTOGGLE_ON
}
@@ -0,0 +1,8 @@
package io.github.Alathra.AlathranCommands.enums;
/**
* What type of teleport is this
*/
public enum TeleportType {
TPA, TPAHERE, TP, TPHERE, WILDTP
}
@@ -0,0 +1,26 @@
package io.github.Alathra.AlathranCommands.events;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class TeleportEvent extends Event implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private boolean cancelled = false;
@Override
public boolean isCancelled() {
return this.cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}
}
@@ -0,0 +1,26 @@
package io.github.Alathra.AlathranCommands.events;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class TeleportGraceEvent extends Event implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private boolean cancelled = false;
@Override
public boolean isCancelled() {
return this.cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}
}
@@ -0,0 +1,26 @@
package io.github.Alathra.AlathranCommands.events;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class TeleportRequestEvent extends Event implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private boolean cancelled = false;
@Override
public boolean isCancelled() {
return this.cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}
}
@@ -0,0 +1,26 @@
package io.github.Alathra.AlathranCommands.events;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class TeleportRequestResolvedEvent extends Event implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private boolean cancelled = false;
@Override
public boolean isCancelled() {
return this.cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}
}
@@ -0,0 +1,49 @@
package io.github.Alathra.AlathranCommands.hooks;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import io.github.Alathra.AlathranCommands.Reloadable;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
public class VaultHook implements Reloadable {
private final AlathranCommands instance;
private RegisteredServiceProvider<Economy> rsp;
public VaultHook(AlathranCommands instance) {
this.instance = instance;
}
@Override
public void onLoad() {
}
@Override
public void onEnable() {
if (!instance.getServer().getPluginManager().isPluginEnabled("Vault"))
return;
setVault(instance.getServer().getServicesManager().getRegistration(Economy.class));
}
@Override
public void onDisable() {
setVault(null);
}
public boolean isVaultLoaded() {
return rsp != null;
}
/**
* Gets vault. Should only be used following {@link #isVaultLoaded()}.
*
* @return vault instance
*/
public Economy getVault() {
return rsp.getProvider();
}
private void setVault(RegisteredServiceProvider<Economy> rsp) {
this.rsp = rsp;
}
}
@@ -0,0 +1,34 @@
package io.github.Alathra.AlathranCommands.listener;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import io.github.Alathra.AlathranCommands.Reloadable;
import io.github.Alathra.AlathranCommands.listener.player.JoinListener;
import io.github.Alathra.AlathranCommands.listener.player.QuitListener;
import org.bukkit.event.HandlerList;
/**
* A class to handle registration of event listeners.
*/
public class ListenerHandler implements Reloadable {
private final AlathranCommands instance;
public ListenerHandler(AlathranCommands instance) {
this.instance = instance;
}
@Override
public void onLoad() {
}
@Override
public void onEnable() {
// Register listeners here
instance.getServer().getPluginManager().registerEvents(new JoinListener(), instance);
instance.getServer().getPluginManager().registerEvents(new QuitListener(), instance);
}
@Override
public void onDisable() {
HandlerList.unregisterAll(instance);
}
}
@@ -0,0 +1,18 @@
package io.github.Alathra.AlathranCommands.listener.player;
import io.github.Alathra.AlathranCommands.data.PlayerManager;
import io.github.Alathra.AlathranCommands.data.model.PlayerData;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class JoinListener implements Listener {
private final PlayerManager playerManager = PlayerManager.getInstance();
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
playerManager.setPlayer(p.getUniqueId(), new PlayerData());
}
}
@@ -0,0 +1,17 @@
package io.github.Alathra.AlathranCommands.listener.player;
import io.github.Alathra.AlathranCommands.data.PlayerManager;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class QuitListener implements Listener {
private final PlayerManager playerManager = PlayerManager.getInstance();
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
Player p = e.getPlayer();
playerManager.removePlayer(p.getUniqueId());
}
}
@@ -0,0 +1,97 @@
package io.github.Alathra.AlathranCommands.runnable;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import io.github.Alathra.AlathranCommands.data.model.TPARequest;
import io.github.Alathra.AlathranCommands.events.TeleportGraceEvent;
import com.github.milkdrinkers.colorparser.ColorParser;
import io.github.Alathra.AlathranCommands.config.TeleportConfigHandler;
import io.github.Alathra.AlathranCommands.utils.TPCfg;
import io.github.Alathra.AlathranCommands.utils.TeleportMessage;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CompletableFuture;
/**
* Start a runnable that executes teleport request at the end of teleport grace period
*/
public class TeleportGraceTask implements Runnable {
private final static boolean canMove = TPCfg.get().getBoolean("Settings.TPA.Grace.Allow-movement");
private final TPARequest request;
private final Location teleporterLocation; // Original location of teleporter, used to determine wether they moved
private final CompletableFuture<Boolean> future;
private final long timeStarted = System.currentTimeMillis();
private final long timeGrace;
private int taskId;
public TeleportGraceTask(final TPARequest request, final long timeGrace, final CompletableFuture<Boolean> future) {
this.request = request;
this.future = future;
this.teleporterLocation = request.getOrigin().getLocation();
this.timeGrace = timeGrace;
final TeleportGraceEvent e = new TeleportGraceEvent();
Bukkit.getServer().getPluginManager().callEvent(e);
if (e.isCancelled()) {
future.complete(false);
}
TeleportMessage.requestTeleporting(this.timeGrace, this.request);
this.taskId = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(AlathranCommands.getInstance(), this, 0, 10).getTaskId();
}
@Override
public void run() {
// Check is origin online and has location
if (!request.getOrigin().isOnline()) {
switch (request.getType()) {
case TPA, TPAHERE -> request.getTarget().sendMessage(ColorParser.of(TPCfg.get().getString("Messages.error-target-cancel-originnotonline")).build());
}
cancelTask();
return;
}
// Is target online and has location
if (!request.getTarget().isOnline()) {
switch (request.getType()) {
case TPA, TPAHERE -> request.getOrigin().sendMessage(ColorParser.of(TPCfg.get().getString("Messages.error-origin-cancel-targetnotonline")).build());
}
cancelTask();
return;
}
// Cancel if target moves
final @Nullable Location teleporter = switch (request.getType()) {
case TPA -> request.getOrigin().getLocation();
case TPAHERE -> request.getTarget().getLocation();
default -> null;
};
if (!canMove && teleporter != null && teleporterLocation.distance(teleporter) > 0.3) {
TeleportMessage.requestTeleportCancel(this.request);
cancelTask();
return;
}
// Check if we should teleport
final long timeCurrent = System.currentTimeMillis();
if (timeCurrent > timeStarted + timeGrace) {
cancelTask();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AlathranCommands.getInstance(), new TeleportTask(request, future));
}
}
void cancelTask() {
if (this.taskId == -1) return;
try {
Bukkit.getServer().getScheduler().cancelTask(this.taskId);
future.complete(false);
} finally {
this.taskId = -1;
}
}
}
@@ -0,0 +1,21 @@
package io.github.Alathra.AlathranCommands.runnable;
import io.github.Alathra.AlathranCommands.data.model.TPARequest;
import io.github.Alathra.AlathranCommands.utils.TeleportUtils;
import java.util.concurrent.CompletableFuture;
public class TeleportTask implements Runnable {
private final TPARequest request;
private final CompletableFuture<Boolean> future;
public TeleportTask(TPARequest request, CompletableFuture<Boolean> future) {
this.request = request;
this.future = future;
}
@Override
public void run() {
TeleportUtils.asyncTeleport(request, future);
}
}
@@ -0,0 +1,11 @@
package io.github.Alathra.AlathranCommands.utils;
import org.jetbrains.annotations.Nullable;
@Deprecated
public interface ConfigUtil {
@Deprecated // TODO All current usages (and the message strings) of this should be migrated from the default config to TeleportConfigHandler AKA TPCfg
default @Nullable String getMsg(String path) {
return null;
}
}
@@ -0,0 +1,21 @@
package io.github.Alathra.AlathranCommands.utils;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
import org.jetbrains.annotations.NotNull;
/**
* A class that provides shorthand access to {@link AlathranCommands#getComponentLogger}.
*/
public class Logger {
/**
* Get component logger. Shorthand for:
*
* @return the component logger {@link AlathranCommands#getComponentLogger}.
*/
@NotNull
public static ComponentLogger get() {
return AlathranCommands.getInstance().getComponentLogger();
}
}
@@ -0,0 +1,19 @@
package io.github.Alathra.AlathranCommands.utils;
import com.github.milkdrinkers.Crate.Config;
import io.github.Alathra.AlathranCommands.AlathranCommands;
import io.github.Alathra.AlathranCommands.config.TeleportConfigHandler;
import org.jetbrains.annotations.NotNull;
/**
* Convenience class for accessing {@link TeleportConfigHandler#getConfig}
*/
public abstract class TPCfg {
/**
* Convenience method for {@link TeleportConfigHandler#getConfig} to getConnection {@link Config}
*/
@NotNull
public static Config get() {
return AlathranCommands.getInstance().getTeleportConfigHandler().getConfig();
}
}
@@ -0,0 +1,134 @@
package io.github.Alathra.AlathranCommands.utils;
import com.github.milkdrinkers.colorparser.ColorParser;
import io.github.Alathra.AlathranCommands.data.model.TPARequest;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.title.Title;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.time.Duration;
/**
* Utility class for sending teleport related messages to players.
*/
public class TeleportMessage {
public static void requestSend(TPARequest request) {
final Player origin = request.getOrigin();
final Player target = request.getTarget();
final Component requestSent = ColorParser.of(TPCfg.get().getString("Messages.request-sent-origin")).parseMinimessagePlaceholder("target", target.getName()).build();
final Component accept = ColorParser.of(TPCfg.get().getString("Messages.request-click-accept")).parseStringPlaceholder("%username%", origin.getName()).build();
final Component deny = ColorParser.of(TPCfg.get().getString("Messages.request-click-deny")).parseStringPlaceholder("%username%", origin.getName()).build();
@Nullable String tpa = switch (request.getType()) {
case TPA -> TPCfg.get().getString("Messages.request-sent-target-tpa");
case TPAHERE -> TPCfg.get().getString("Messages.request-sent-target-tpahere");
default -> null;
};
if (tpa != null) {
target.sendMessage(
ColorParser.of(tpa)
.parseMinimessagePlaceholder("player", origin.getName())
.parseMinimessagePlaceholder("accept", accept)
.parseMinimessagePlaceholder("deny", deny)
.build()
);
}
origin.sendMessage(requestSent);
}
public static void requestTeleported(TPARequest request) {
final Player origin = request.getOrigin();
final Player target = request.getTarget();
final String titleString = TPCfg.get().getString("Messages.teleporting-origin-title");
final String subTitleString = TPCfg.get().getString("Messages.teleporting-origin-subtitle");
final Component titleMain = ColorParser.of(titleString).build();
final Component subMain = ColorParser.of(subTitleString).build();
final Title.Times times = Title.Times.times(Duration.ofMillis(250), Duration.ofSeconds(2), Duration.ofMillis(250));
final Title title = Title.title(titleMain, subMain, times);
switch (request.getType()) {
case TPA -> {
if (isTitlesEnabled()) {
origin.showTitle(title);
}
origin.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.teleporting-origin")).build());
target.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.teleporting-target")).parseMinimessagePlaceholder("origin", origin.getName()).build());
}
case TPAHERE -> {
if (isTitlesEnabled()) {
target.showTitle(title);
}
target.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.teleporting-origin")).build());
origin.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.teleporting-target")).parseMinimessagePlaceholder("origin", target.getName()).build());
}
}
}
public static void requestTeleporting(long secs, TPARequest request) {
if (!isTitlesEnabled()) return;
final String titleString = TPCfg.get().getString("Messages.grace-origin-title");
final String subTitleString = TPCfg.get().getString("Messages.grace-origin-subtitle");
final Component titleMain = ColorParser.of(titleString).build();
final Component subMain = ColorParser.of(subTitleString).build();
final Title.Times times = Title.Times.times(Duration.ofMillis(250), Duration.ofSeconds(secs), Duration.ofMillis(250));
final Title title = Title.title(titleMain, subMain, times);
switch (request.getType()) {
case TPA -> {
request.getOrigin().showTitle(title);
}
case TPAHERE -> {
request.getTarget().showTitle(title);
}
}
}
public static void requestTeleportCancel(TPARequest request) {
final Player origin = request.getOrigin();
final Player target = request.getTarget();
final String titleString = TPCfg.get().getString("Messages.error-origin-cancel-title");
final String subTitleString = TPCfg.get().getString("Messages.error-origin-cancel-title");
final Component titleMain = ColorParser.of(titleString).build();
final Component subMain = ColorParser.of(subTitleString).build();
final Title.Times times = Title.Times.times(Duration.ofMillis(250), Duration.ofSeconds(2), Duration.ofMillis(250));
final Title title = Title.title(titleMain, subMain, times);
switch (request.getType()) {
case TPA -> {
if (isTitlesEnabled()) {
origin.showTitle(title);
}
origin.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.error-origin-cancel-moved")).parseMinimessagePlaceholder("player", origin.getName()).build());
target.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.error-target-cancel-moved")).parseMinimessagePlaceholder("player", origin.getName()).build());
}
case TPAHERE -> {
if (isTitlesEnabled()) {
target.showTitle(title);
}
target.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.error-origin-cancel-moved")).parseMinimessagePlaceholder("player", origin.getName()).build());
origin.sendMessage(ColorParser.of(TPCfg.get().getString("Messages.error-target-cancel-moved")).parseMinimessagePlaceholder("player", origin.getName()).build());
}
}
}
private static boolean isTitlesEnabled() {
return TPCfg.get().getBoolean("Settings.TPA.Titles");
}
}
@@ -0,0 +1,52 @@
package io.github.Alathra.AlathranCommands.utils;
import io.github.Alathra.AlathranCommands.data.model.TPARequest;
import io.github.Alathra.AlathranCommands.events.TeleportEvent;
import org.bukkit.Bukkit;
import java.util.concurrent.CompletableFuture;
public class TeleportUtils {
// TODO Messages
public static void asyncTeleport(TPARequest request, final CompletableFuture<Boolean> future) {
if (request.isExpired()) {
future.complete(false);
return;
}
if (!request.getOrigin().isOnline()) {
future.complete(false);
return;
}
if (!request.getTarget().isOnline()) {
future.complete(false);
return;
}
// TODO If cooldowns enabled, check cooldown
/*if (request.hasCooldown()) {
}*/
// TODO If balance enabled, check cooldown
/*if (!request.canAfford()) {
future.complete(false);
return;
}*/
final TeleportEvent e = new TeleportEvent();
Bukkit.getServer().getPluginManager().callEvent(e);
if (e.isCancelled()) {
future.complete(false);
return;
}
TeleportMessage.requestTeleported(request);
switch (request.getType()) {
case TPA -> request.getOrigin().teleportAsync(request.getTarget().getLocation());
case TPAHERE -> request.getTarget().teleportAsync(request.getOrigin().getLocation());
}
future.complete(true);
}
}
+162
View File
@@ -0,0 +1,162 @@
# TeleportConfigHandler for AlathranCommands
# Version v1.7.1
# Author: jklmao
# # # # # # # # # # # # # # # # # # # # # # # # #
# #
# TeleportConfigHandler #
# #
# # # # # # # # # # # # # # # # # # # # # # # # #
# Be aware of all warnings! #
# # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Place Holders #
# #
# # # # # # # # # # # # # # # # # # # # # # # # #
# Use '<player>' for the player who sent the request.
# Use '<accept>' for the 'Click-to-accept' message.
# Use '<deny>' for the 'Click-to-deny' message.
# Use '<target>' for the player who they wanted to teleport to, and for the 'Player-sent-request' message.
# Example: /tpa <player>, where <player> is '<target>'.
Player-only-command: '<red>Only players can use this command!'
Insufficient-permission: '<red>You do not have sufficient permission!'
Player-deny-tpa-message: '<red>Teleportation request has been denied.'
Target-deny-tpa-message: '<red>Teleportation request has been denied.'
Target-teleportion-canceled: '<red>Teleportation canceled...'
Player-got-accepted-tpa: '<blue>Teleportation request has been accepted.'
Countdown-until-tpa: '<yellow>Teleporting in 3 seconds...'
Player-no-pendingtpa-message: '<red>You do not have a pending request!'
Target-accepted-tpa-request: '<yellow>Request for teleportation is accepted.'
Target-is-offline: '<red>This player is offline!'
No-player-found: '<red>This player does not exist!'
Player-teleporting-self: '<red>You can not teleport yourself!'
Player-already-requested: '<red>You already requested, please wait..'
Player-teleportation-request-expire: '<red>Teleportation request has expired.'
Target-teleportation-request-expire: '<red>Teleportation request has expired.'
Player-currently-teleporting: '<blue>Teleporting...'
Target-currently-teleporting: '<yellow>Teleporting...'
Player-TpToggle-Off: '<yellow>Teleportation <gold>OFF'
Player-TpToggle-On: '<yellow>Teleportation <gold>ON'
Target-Is-TpToggled: '<gold><target> <yellow>has teleportation off'
Player-Is-TpToggled: '<red>You are tptoggled!'
TpToggle-While-Teleporting: '<red>Cannot TpToggle while teleporting!'
Tpacancel-message: '<gold>Tpa request has been canceled.'
# TPA request expires in seconds
Request-expire-time: 120
# Seconds until tpa
# Please use whole numbers
Seconds-until-tpa: 3
# Becareful in this part!
# This is when a player uses not enough args
# For example, when a player does '/tpa', it will say 'Usage: /tpa <player>'
# So please fit the correct command under the correct message!
# P.S '/tpohere' is also '/s' (essentials-type command).
Tpa-usage: '<red>Use: /tpa <player>'
Tpahere-usage: '<red>Use: /tpahere <player>'
Tpaccept-usage: '<red>Use: /tpaccept <player>'
Tpdeny-usage: '<red>Use: /tpadeny <player>'
Tpo-usage: '<red>Use: /tpo <player>'
Tpohere-usage: '<red>Use: /tpohere <player> or /s <player>'
# # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Please Read! #
# #
# # # # # # # # # # # # # # # # # # # # # # # # #
# This section is when a player gets a tpa request
# Since the code used is broken into many parts, there will be many messages.
# Whatever you do to the "Click-to-x" messages, will be the same in the 'Tpa-message'
# Be careful!
# Lets you choose if you want players to be able
# to move before being teleported
Allow-player-to-move: false
Player-moved-before-tp: '<gold>The request was canceled because <player> moved!'
Player-sent-request: '<yellow>You have sent a request to <gold><target>'
Tpa-message: |-
<br>
<yellow><player> <gold>has requested to teleport to you.
<gold>Click <accept> <gold>to accept or click <deny> <gold>to deny.
<gold>The request expires in 120 seconds.
<br>
Tpahere-message: |-
<br>
<yellow><player> <gold>has requested to teleport you to them.
<gold>Click <accept> <gold>to accept or click <deny> <gold>to deny.
<gold>The request expires in 120 seconds.
<br>
# This will put additional spaces for the accept/deny messages
Center-accept-deny-msg: true
Click-to-accept: '<hover:show_text:"<green>Click to accept"><click:run_command:/tpaccept %username%><green><bold>[Accept]<reset>'
Click-to-deny: '<hover:show_text:"<red>Click to deny"><click:run_command:/tpadeny %username%><red><bold>[Deny]<reset>'
Hover-message-on-accept: '<green>Click to accept'
Hover-message-on-deny: '<red>Click to deny'
#
# On-Screen Messages
# It pops up in the middle of the player's screen
#
Send-on-screen-message: true
# When a player accepts a tp
On-screen-teleporting:
- '<gold>Teleporting...'
- '<yellow>Do not move!'
# When a player has successfully tp'd.
On-screen-teleported: '<green>Teleported!'
# If a player moves while they are being tp'd
On-screen-canceled-tp: '<red>Canceled TP!'
#~~~~~~~~~~~~~~~~~~#
# More Coming Soon!#
#~~~~~~~~~~~~~~~~~~#
+70
View File
@@ -0,0 +1,70 @@
# Teleport messages
Messages:
# Tpa section
tptoggle-on: 'Teleportation requests enabled.'
tptoggle-off: 'Teleportation requests enabled.'
tptoggle-busy: 'Cannot toggle teleportation requests while teleporting.'
error-origin-istarget: 'You can''t teleport to yourself.'
error-origin-target-toggled-off: '<target> has teleportation requests off.'
error-origin-outstanding-request: 'You already have a outstanding request. Use /tpcancel.'
error-origin-no-outstanding-request: 'You have no outstanding requests.'
error-origin-no-outgoing-request: 'You have no outgoing requests.'
error-origin-target-offline: 'That player is offline.'
request-sent-origin: 'Teleportation request sent to <target>.'
request-sent-target-tpa: |-
<br>
<yellow><player> <gold>has requested to teleport to you.
<gold>Click <accept> <gold>to accept or click <deny> <gold>to deny.
<gold>The request expires in 120 seconds.
<br>
request-sent-target-tpahere: |-
<br>
<yellow><player> <gold>has requested to teleport you to them.
<gold>Click <accept> <gold>to accept or click <deny> <gold>to deny.
<gold>The request expires in 120 seconds.
<br>
request-accepted-origin: 'Teleportation request to <target> accepted.'
request-accepted-target: 'Teleportation request from <origin> accepted.'
request-denied-origin: 'Teleportation request to <target> denied.'
request-denied-target: 'Teleportation request denied.'
request-canceled-origin: 'Teleportation request to <target> has been canceled.'
request-canceled-target: 'Teleportation request from <origin> canceled.'
request-canceled-isbusy: 'Teleportation request canceled.'
request-grace-begin-origin: 'Teleporting in <time> seconds, please don''t move.'
request-click-accept: '<hover:show_text:"<green>Click to accept"><click:run_command:/tpaccept %username%><green><bold>[Accept]<reset>'
request-click-deny: '<hover:show_text:"<red>Click to deny"><click:run_command:/tpadeny %username%><red><bold>[Deny]<reset>'
error-origin-cancel-targetnotonline: 'Teleport canceled because the other player is no longer online.'
error-target-cancel-originnotonline: 'Teleport canceled because the other player is no longer online.'
error-origin-cancel-moved: 'Teleport canceled because you moved.'
error-target-cancel-moved: 'Teleport canceled because the other person moved.'
error-origin-cancel-title: 'Canceled TP'
error-origin-cancel-subtitle: ''
grace-origin-title: '<purple><bold>Teleporting'
grace-origin-subtitle: '<white><italic>Don''t move!'
teleporting-origin-title: '<green>Teleported'
teleporting-origin-subtitle: ''
teleporting-origin: '<green>Teleporting...'
teleporting-target: '<origin> Teleported to you.'
Settings:
TPA:
# Enable titles informing players
Titles: false
# Request timeout in seconds
Timeout: 30
# Grace period (teleport warmup) settings
Grace:
# Warmup time before teleport in seconds
Time: 5
# Should movement cancel the teleport
Allow-movement: false
# Set to 0 to effectively disable feature, needs to be an integer
Price: 0
# Cooldown time in seconds (Set to 0 to effectively disable)
Cooldown: 0