Compare commits

27 Commits
Author SHA1 Message Date
NotAlexNoyle c45833c994 Point submodules at canonical Gitea repositories 2026-11-01 12:46:25 -05:00
NotAlexNoyle c31a2f0c1e Exclude CODEOWNERS from language statistics 2026-10-28 15:32:11 -04:00
NotAlexNoyle dd3ccfce9b Add CODEOWNERS (one staff approval) 2026-10-28 15:32:11 -04:00
NotAlexNoyle 00a3d1e502 Update Utilities-OG API 2026-09-14 02:03:12 -04:00
NotAlexNoyle 353405168b Update Utilities-OG API 2026-07-20 00:51:21 -04:00
NotAlexNoyle 53d451b266 Update Utilities-OG API 2026-05-20 11:19:54 -04:00
NotAlexNoyle 0af41380a5 Update Utilities-OG 2026-05-11 00:48:27 -04:00
NotAlexNoyle 645d658ad8 Update Utilities-OG API 2026-04-20 02:01:46 -04:00
NotAlexNoyle 7ccd34c928 Update Utilities-OG API 2026-04-05 13:18:37 -04:00
NotAlexNoyle c2676966c3 Update Utilities-OG API 2026-03-30 05:07:00 -04:00
NotAlexNoyle 17347a1378 Update Utilities-OG 2026-03-25 11:55:50 -04:00
NotAlexNoyle 0731b425b4 Update Utilities-OG 2025-12-11 07:14:22 -05:00
NotAlexNoyle 2f18fb37fb Update Utilities-OG dependency 2025-12-07 18:38:31 -05:00
NotAlexNoyle 4892e37aca Update gradle to 8.14.3, add formatting 2025-08-16 11:14:02 -04:00
NotAlexNoyle 5809f5ae72 Update Utilities-OG dependency 2025-07-07 11:37:06 -04:00
NotAlexNoyle 11d5e4bf51 Update Utilities-OG dependency 2025-06-23 19:58:43 -04:00
NotAlexNoyle e6be6980c4 Update gradle to 8.14.2, add auto-formatting 2025-06-18 19:57:54 -04:00
NotAlexNoyle d7d9d6008f Update gradle to 8.14.1 2025-06-06 00:30:19 -04:00
NotAlexNoyle de86d07dad Update Utilities-OG dependency 2025-06-06 00:28:48 -04:00
NotAlexNoyle ef9336defb Update gradle syntax 2025-06-06 00:24:48 -04:00
NotAlexNoyle 465e21726e Update kotlin 2024-11-01 13:35:51 +00:00
NotAlexNoyle a0353d09b5 Update Utilities-OG 2024-11-01 12:30:08 +00:00
NotAlexNoyle 32bd2c6477 Include gradle jar 2024-11-01 06:40:29 +00:00
NotAlexNoyle 697d8d92e8 Fix gradle wrapper 2024-11-01 05:46:57 +00:00
NotAlexNoyle a29c370fc4 Update Utilities-OG 2024-10-11 00:20:47 +00:00
NotAlexNoyle e2e4b8c713 1.19.4 Update by TrueOG Network 2024-07-20 04:52:40 -04:00
NotAlexNoyle 454506a1b8 Switch to gradle 2024-07-20 01:08:41 -04:00
22 changed files with 4643 additions and 3203 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
.gitea/CODEOWNERS linguist-detectable=false
+3
View File
@@ -0,0 +1,3 @@
# Pull requests request review from the eligible staff team(s).
# One approval from either an Admin or Developer satisfies branch protection.
* @trueog/Admins @trueog/Developers
+25 -3
View File
@@ -1,15 +1,37 @@
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/target/
/.classpath
/.project
replay_pid*
# macOS system files
.DS_Store
# gradle build output files
build/
.gradle/
# eclipse project files
.settings/
.project
.classpath
bin/
+3
View File
@@ -0,0 +1,3 @@
[submodule "libs/Utilities-OG"]
path = libs/Utilities-OG
url = https://git.trueog.net/trueog/Utilities-OG
Executable
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/bash
# Fetch all submodule content.
git submodule update --force --recursive --init
+103
View File
@@ -0,0 +1,103 @@
/* ------------------------------ Plugins ------------------------------ */
plugins {
id("java") // Import Java plugin.
id("java-library") // Import Java Library plugin.
id("com.diffplug.spotless") version "8.1.0" // Import Spotless plugin.
id("com.gradleup.shadow") version "8.3.9" // Import Shadow plugin.
id("checkstyle") // Import Checkstyle plugin.
eclipse // Import Eclipse plugin.
kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin.
}
/* --------------------------- JDK / Kotlin ---------------------------- */
java {
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
toolchain { // Select Java toolchain.
languageVersion.set(JavaLanguageVersion.of(17)) // Use JDK 17.
vendor.set(JvmVendorSpec.GRAAL_VM) // Use GraalVM CE.
}
}
kotlin { jvmToolchain(17) }
/* ----------------------------- Metadata ------------------------------ */
group = "com.hm.mcshared" // Declare bundle identifier.
version = "1.1.8" // Declare plugin version (will be in .jar).
val apiVersion = "1.19" // Declare minecraft server target version.
/* ----------------------------- Resources ----------------------------- */
tasks.named<ProcessResources>("processResources") {
val props = mapOf("version" to version, "apiVersion" to apiVersion)
inputs.properties(props) // Indicates to rerun if version changes.
filesMatching("plugin.yml") { expand(props) }
from("LICENSE") { into("/") } // Bundle licenses into jarfiles.
}
/* ---------------------------- Repos ---------------------------------- */
repositories {
mavenCentral() // Import the Maven Central Maven Repository.
gradlePluginPortal() // Import the Gradle Plugin Portal Maven Repository.
maven { url = uri("https://repo.purpurmc.org/snapshots") } // Import the PurpurMC Maven Repository.
}
/* ---------------------- Java project deps ---------------------------- */
dependencies {
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare Purpur API version to be packaged.
compileOnly("io.github.miniplaceholders:miniplaceholders-api:2.2.3") // Import MiniPlaceholders API.
compileOnlyApi(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG Java API (from source).
}
/* ---------------------- Reproducible jars ---------------------------- */
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .jars
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
/* ----------------------------- Shadow -------------------------------- */
tasks.shadowJar {
exclude("io.github.miniplaceholders.*") // Exclude the MiniPlaceholders package from being shadowed.
archiveClassifier.set("") // Use empty string instead of null.
minimize()
}
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) } // Build depends on spotless and shadow.
/* --------------------------- Javac opts ------------------------------- */
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters") // Enable reflection for java code.
options.isFork = true // Run javac in its own process.
options.compilerArgs.add("-Xlint:deprecation") // Trigger deprecation warning messages.
options.encoding = "UTF-8" // Use UTF-8 file encoding.
}
/* ----------------------------- Auto Formatting ------------------------ */
spotless {
java {
eclipse().configFile("config/formatter/eclipse-java-formatter.xml") // Eclipse java formatting.
leadingTabsToSpaces() // Convert leftover leading tabs to spaces.
removeUnusedImports() // Remove imports that aren't being called.
}
kotlinGradle {
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } // JetBrains Kotlin formatting.
target("build.gradle.kts", "settings.gradle.kts") // Gradle files to format.
}
}
checkstyle {
toolVersion = "10.18.1" // Declare checkstyle version to use.
configFile = file("config/checkstyle/checkstyle.xml") // Point checkstyle to config file.
isIgnoreFailures = true // Don't fail the build if checkstyle does not pass.
isShowViolations = true // Show the violations in any IDE with the checkstyle plugin.
}
tasks.named("compileJava") {
dependsOn("spotlessApply") // Run spotless before compiling with the JDK.
}
tasks.named("spotlessCheck") {
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
}
+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="TreeWalker">
<module name="FinalLocalVariable"/>
<module name="AvoidStarImport"/>
<module name="Indentation">
<property name="severity" value="ignore"/>
</module>
</module>
<module name="RegexpSingleline">
<property name="format" value="\borg\.junit\.jupiter\.api\.Assertions\.fail\s*\(\s*&quot;Not yet implemented&quot;\s*\)\s*;"/>
<property name="message" value="Remove placeholder fail() and implement the test."/>
<property name="ignoreCase" value="true"/>
<property name="severity" value="warning"/>
</module>
<module name="RegexpSingleline">
<property name="format" value="(?&lt;!\w)fail\s*\(\s*&quot;Not yet implemented&quot;\s*\)\s*;"/>
<property name="message" value="Remove placeholder fail() and implement the test."/>
<property name="severity" value="warning"/>
</module>
</module>
+404
View File
@@ -0,0 +1,404 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="23">
<profile kind="CodeFormatterProfile" name="TrueOG Network Formatting" version="23">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_not_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case_after_arrow" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.align_arrows_in_switch_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow" value="20"/>
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
</profile>
</profiles>
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.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+251
View File
@@ -0,0 +1,251 @@
#!/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.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# 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/platforms/jvm/plugins-application/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 -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || 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="\\\"\\\""
# 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, 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" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# 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
+94
View File
@@ -0,0 +1,94 @@
@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
@rem SPDX-License-Identifier: Apache-2.0
@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. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
: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
+1
Submodule libs/Utilities-OG added at 8b5c86cc9c.
-89
View File
@@ -1,89 +0,0 @@
<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.hm.mcshared</groupId>
<artifactId>MCShared</artifactId>
<version>1.1.7</version>
<packaging>jar</packaging>
<name>MCShared</name>
<url>https://github.com/PyvesB/MCShared</url>
<description>A small library containing common functionnality for Minecraft plugins.</description>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/PyvesB/MCShared/issues</url>
</issueManagement>
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<github.global.server>github</github.global.server>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
</configuration>
</plugin>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<configuration>
<message>Maven artifacts for ${project.version}</message>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
<branch>refs/heads/mvn-repo</branch>
<includes>
<include>**/*</include>
</includes>
<merge>true</merge>
<repositoryName>MCShared</repositoryName>
<repositoryOwner>PyvesB</repositoryOwner>
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
+13
View File
@@ -0,0 +1,13 @@
rootProject.name = "MCShared-OG"
ProcessBuilder("sh", "bootstrap.sh").directory(rootDir).inheritIO().start().let {
if (it.waitFor() != 0) throw GradleException("bootstrap.sh failed")
}
file("libs")
.listFiles()
?.filter { it.isDirectory && !it.name.startsWith(".") }
?.forEach { dir ->
include(":libs:${dir.name}")
project(":libs:${dir.name}").projectDir = dir
}
@@ -7,80 +7,98 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Class representing an event fired when a player changes the ownership of one of his pets. The event is fired by the
* PetMaster plugin, and this class can be used by any plugin that needs to listen to this event.
*
* Class representing an event fired when a player changes the ownership of one
* of his pets. The event is fired by the PetMaster plugin, and this class can
* be used by any plugin that needs to listen to this event.
*
* @author Pyves
*
*/
public class PlayerChangeAnimalOwnershipEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private static final HandlerList handlers = new HandlerList();
private final AnimalTamer oldOwner;
private final AnimalTamer newOwner;
private final Tameable ownedAnimal;
private final AnimalTamer oldOwner;
private final AnimalTamer newOwner;
private final Tameable ownedAnimal;
private boolean cancelled;
private boolean cancelled;
/**
* Creates a new PlayerChangeAnimalOwnershipEvent with information about old and new owners as well as the animal
* involved in the transaction.
*
* @param oldOwner Old owner of the tameable animal.
* @param newOwner New owner of the tameable animal.
* @param ownedAnimal Tameable animal whose ownership was changed.
*/
public PlayerChangeAnimalOwnershipEvent(AnimalTamer oldOwner, AnimalTamer newOwner, Tameable ownedAnimal) {
this.oldOwner = oldOwner;
this.newOwner = newOwner;
this.ownedAnimal = ownedAnimal;
this.cancelled = false;
}
/**
* Creates a new PlayerChangeAnimalOwnershipEvent with information about old and
* new owners as well as the animal involved in the transaction.
*
* @param oldOwner Old owner of the tameable animal.
* @param newOwner New owner of the tameable animal.
* @param ownedAnimal Tameable animal whose ownership was changed.
*/
public PlayerChangeAnimalOwnershipEvent(AnimalTamer oldOwner, AnimalTamer newOwner, Tameable ownedAnimal) {
@Override
public HandlerList getHandlers() {
return handlers;
}
this.oldOwner = oldOwner;
this.newOwner = newOwner;
this.ownedAnimal = ownedAnimal;
this.cancelled = false;
public static HandlerList getHandlerList() {
return handlers;
}
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public HandlerList getHandlers() {
@Override
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
return handlers;
/**
* Returns the previous owner of the tameable animal.
*
* @return Old owner of the tameable animal.
*/
public AnimalTamer getOldOwner() {
return oldOwner;
}
}
/**
* Returns the new owner of the tameable animal.
*
* @return New owner of the tameable animal.
*/
public AnimalTamer getNewOwner() {
return newOwner;
}
public static HandlerList getHandlerList() {
return handlers;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
/**
* Returns the previous owner of the tameable animal.
*
* @return Old owner of the tameable animal.
*/
public AnimalTamer getOldOwner() {
return oldOwner;
}
/**
* Returns the new owner of the tameable animal.
*
* @return New owner of the tameable animal.
*/
public AnimalTamer getNewOwner() {
return newOwner;
}
/**
* Returns the tameable animal whose ownership was changed.
*
* @return Tameable animal whose ownership was changed.
*/
public Tameable getOwnedAnimal() {
return ownedAnimal;
}
/**
* Returns the tameable animal whose ownership was changed.
*
* @return Tameable animal whose ownership was changed.
*/
public Tameable getOwnedAnimal() {
return ownedAnimal;
}
}
@@ -5,158 +5,199 @@ import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
/**
* Class to take care of Yaml configuration files by providing some additional methods to the standard Bukkit
* YamlConfiguration class. This class enables more modularity, and contains methods to set new configuration parameters
* Class to take care of Yaml configuration files by providing some additional
* methods to the standard Bukkit YamlConfiguration class. This class enables
* more modularity, and contains methods to set new configuration parameters
* with comments as well as various other convenience methods.
*
*
* @author Pyves
*
*/
public class CommentedYamlConfiguration extends YamlConfiguration {
private final FileManager manager;
private final JavaPlugin plugin;
private final FileManager manager;
private final JavaPlugin plugin;
private int numOfComments;
private int numOfComments;
/**
* Creates a new CommentedYamlConfiguration object representing one of the plugin's configuration files.
*
* @param fileName Name of the configuration file situated in the resource folder of the plugin.
* @param plugin The plugin making use of the configuration file.
*/
public CommentedYamlConfiguration(String fileName, JavaPlugin plugin) {
this(fileName, fileName, plugin);
}
/**
* Creates a new CommentedYamlConfiguration object representing one of the
* plugin's configuration files.
*
* @param fileName Name of the configuration file situated in the resource
* folder of the plugin.
* @param plugin The plugin making use of the configuration file.
*/
public CommentedYamlConfiguration(String fileName, JavaPlugin plugin) {
/**
* Creates a new CommentedYamlConfiguration object representing one of the plugin's configuration files. This
* constructor takes a plugin resource name that may be different for the file name used on the server.
*
* @param fileName Name of the configuration file situated in the resource folder of the plugin.
* @param pluginResourceName The name of the plugin resource.
* @param plugin The plugin making use of the configuration file.
*/
public CommentedYamlConfiguration(String fileName, String pluginResourceName, JavaPlugin plugin) {
super();
if (fileName == null || fileName.isEmpty()) {
throw new IllegalArgumentException("Invalid file name.");
}
this.plugin = plugin;
manager = new FileManager(fileName, pluginResourceName, plugin);
}
this(fileName, fileName, plugin);
/**
* Gets a set containing all keys in this section, with only the keys of any direct children, and not their own
* children. Helper method.
*
* @param path
* @return Set containing the shallow configuration keys for the given path.
*/
public Set<String> getShallowKeys(String path) {
return getConfigurationSection(path).getKeys(false);
}
}
/**
* Gets the requested ConfigurationSection by path. Returns an empty ConfigurationSection if it does not exist.
*
* @param path Path of the ConfigurationSection to get.
* @return Requested ConfigurationSection or empty one.
*/
@Override
public ConfigurationSection getConfigurationSection(String path) {
ConfigurationSection configurationSection = super.getConfigurationSection(path);
return configurationSection == null ? createSection(path) : configurationSection;
}
/**
* Creates a new CommentedYamlConfiguration object representing one of the
* plugin's configuration files. This constructor takes a plugin resource name
* that may be different for the file name used on the server.
*
* @param fileName Name of the configuration file situated in the
* resource folder of the plugin.
* @param pluginResourceName The name of the plugin resource.
* @param plugin The plugin making use of the configuration file.
*/
public CommentedYamlConfiguration(String fileName, String pluginResourceName, JavaPlugin plugin) {
/**
* Gets the requested List by path. Returns a List of type String.
*
* @param path Path of the List to get.
* @return Requested List of Strings.
*/
@SuppressWarnings("unchecked")
@Override
public List<String> getList(String path) {
List<String> list = (List<String>) super.getList(path);
if (list != null) {
return list;
}
return new ArrayList<>();
}
super();
if (fileName == null || fileName.isEmpty()) {
/**
* Sets the specified path to the given value with the given comment.
*
* @param path Path of the object to set.
* @param value New value to set the path to.
* @param comment New comment to set the path to. Ignored if null.
*/
public void set(String path, Object value, String comment) {
if (comment != null) {
// Insert comment as new value in the file; will be converted back to a comment when saved by the
// FileManager.
this.set(plugin.getDescription().getName() + "_COMMENT_" + numOfComments, comment.replace(":", "_COLON_")
.replace("|", "_VERT_").replace("-", "_HYPHEN_").replace(" ", "_SPACE_"));
numOfComments++;
}
this.set(path, value);
}
throw new IllegalArgumentException("Invalid file name.");
/**
* Sets the specified path to the given value with the given comments (one comment per line).
*
* @param path Path of the object to set.
* @param value New value to set the path to.
* @param comments New comments to set the path to. Ignored if empty.
*/
public void set(String path, Object value, String... comments) {
for (String comment : comments) {
// Insert comment as new value in the file; will be converted back to a comment when saved.
this.set(plugin.getDescription().getName() + "_COMMENT_" + numOfComments, comment.replace(":", "_COLON_")
.replace("|", "_VERT_").replace("-", "_HYPHEN_").replace(" ", "_SPACE_"));
numOfComments++;
}
this.set(path, value);
}
}
/**
* Loads or reloads the configuration file from disk.
*
* @throws IOException
* @throws InvalidConfigurationException
*/
public void loadConfiguration() throws IOException, InvalidConfigurationException {
manager.createConfigurationFileIfNotExists();
map.clear();
load(new StringReader(manager.getConfigurationWithReworkedComments()));
numOfComments = manager.getNumberOfComments();
}
this.plugin = plugin;
manager = new FileManager(fileName, pluginResourceName, plugin);
/**
* Saves the configuration file and any modifications that were performed.
*
* @throws IOException
*/
public void saveConfiguration() throws IOException {
String configString = this.saveToString();
manager.saveConfiguration(configString);
}
}
/**
* Gets a set containing all keys in this section, with only the keys of any
* direct children, and not their own children. Helper method.
*
* @param path
* @return Set containing the shallow configuration keys for the given path.
*/
public Set<String> getShallowKeys(String path) {
return getConfigurationSection(path).getKeys(false);
}
/**
* Gets the requested ConfigurationSection by path. Returns an empty
* ConfigurationSection if it does not exist.
*
* @param path Path of the ConfigurationSection to get.
* @return Requested ConfigurationSection or empty one.
*/
@Override
public ConfigurationSection getConfigurationSection(String path) {
ConfigurationSection configurationSection = super.getConfigurationSection(path);
return configurationSection == null ? createSection(path) : configurationSection;
}
/**
* Gets the requested List by path. Returns a List of type String.
*
* @param path Path of the List to get.
* @return Requested List of Strings.
*/
@SuppressWarnings("unchecked")
@Override
public List<String> getList(String path) {
List<String> list = (List<String>) super.getList(path);
if (list != null) {
return list;
}
return new ArrayList<>();
}
/**
* Sets the specified path to the given value with the given comment.
*
* @param path Path of the object to set.
* @param value New value to set the path to.
* @param comment New comment to set the path to. Ignored if null.
*/
public void set(String path, Object value, String comment) {
if (comment != null) {
// Insert comment as new value in the file; will be converted back to a comment
// when saved by the
// FileManager.
this.set(plugin.getPluginMeta().getName() + "_COMMENT_" + numOfComments, comment.replace(":", "_COLON_")
.replace("|", "_VERT_").replace("-", "_HYPHEN_").replace(" ", "_SPACE_"));
numOfComments++;
}
this.set(path, value);
}
/**
* Sets the specified path to the given value with the given comments (one
* comment per line).
*
* @param path Path of the object to set.
* @param value New value to set the path to.
* @param comments New comments to set the path to. Ignored if empty.
*/
public void set(String path, Object value, String... comments) {
for (String comment : comments) {
// Insert comment as new value in the file; will be converted back to a comment
// when saved.
this.set(plugin.getPluginMeta().getName() + "_COMMENT_" + numOfComments, comment.replace(":", "_COLON_")
.replace("|", "_VERT_").replace("-", "_HYPHEN_").replace(" ", "_SPACE_"));
numOfComments++;
}
this.set(path, value);
}
/**
* Loads or reloads the configuration file from disk.
*
* @throws IOException
* @throws InvalidConfigurationException
*/
public void loadConfiguration() throws IOException, InvalidConfigurationException {
manager.createConfigurationFileIfNotExists();
map.clear();
load(new StringReader(manager.getConfigurationWithReworkedComments()));
numOfComments = manager.getNumberOfComments();
}
/**
* Saves the configuration file and any modifications that were performed.
*
* @throws IOException
*/
public void saveConfiguration() throws IOException {
String configString = this.saveToString();
manager.saveConfiguration(configString);
}
/**
* Performs a backup of the configuration; the backup simply makes a copy of the
* file and adds a .bak extension to it.
*
* @throws IOException
*/
public void backupConfiguration() throws IOException {
manager.backupFile();
}
/**
* Performs a backup of the configuration; the backup simply makes a copy of the file and adds a .bak extension to
* it.
*
* @throws IOException
*/
public void backupConfiguration() throws IOException {
manager.backupFile();
}
}
@@ -10,183 +10,254 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import org.bukkit.plugin.java.JavaPlugin;
/**
* Class to take care of the management of plugin files.
* <p>
* For configuration files, this class provides a workaround to keep comments in the file when using Bukkit's
* YamlConfiguration class (otherwise comments are deleted when the file is modified and saved programatically).
* For configuration files, this class provides a workaround to keep comments in
* the file when using Bukkit's YamlConfiguration class (otherwise comments are
* deleted when the file is modified and saved programatically).
* <p>
* Other convenience methods such as doing backups are also provided and can be used for other file types.
*
* Other convenience methods such as doing backups are also provided and can be
* used for other file types.
*
* @author Pyves
*
*/
public class FileManager {
private final JavaPlugin plugin;
private final String pluginResourceName;
private final JavaPlugin plugin;
private final String pluginResourceName;
private File file;
private int numOfComments;
private File file;
private int numOfComments;
/**
* Constructs an instance of the manager.
*
* @param fileName Name of the file situated in the resource folder of the plugin.
* @param plugin The plugin making use of the file.
*/
public FileManager(String fileName, JavaPlugin plugin) {
this(fileName, fileName, plugin);
}
/**
* Constructs an instance of the manager.
*
* @param fileName Name of the file situated in the resource folder of the
* plugin.
* @param plugin The plugin making use of the file.
*/
public FileManager(String fileName, JavaPlugin plugin) {
/**
* Constructs an instance of the manager. This constructor takes a plugin resource name that may be different for
* the file name used on the server.
*
* @param fileName Name of the file situated in the resource folder of the plugin.
* @param pluginResourceName The name of the plugin resource.
* @param plugin The plugin making use of the file.
*/
public FileManager(String fileName, String pluginResourceName, JavaPlugin plugin) {
this.plugin = plugin;
this.pluginResourceName = pluginResourceName;
if (fileName.startsWith("/")) {
file = new File(plugin.getDataFolder() + fileName.replace("/", File.separator));
} else {
file = new File(plugin.getDataFolder() + File.separator + fileName.replace("/", File.separator));
}
}
this(fileName, fileName, plugin);
/**
* Performs a backup of the file contained in the plugin's data folder; the backup simply makes a copy of the file
* and adds a .bak extension to it.
*
* @throws IOException
*/
public void backupFile() throws IOException {
File backupFile = new File(plugin.getDataFolder(), file.getName() + ".bak");
// Overwrite previous backup only if a newer version of the file exists.
if (file.lastModified() > backupFile.lastModified() && file.exists()) {
try (FileInputStream inStream = new FileInputStream(file);
FileOutputStream outStream = new FileOutputStream(backupFile)) {
byte[] buffer = new byte[1024];
int length;
while ((length = inStream.read(buffer)) > 0) {
outStream.write(buffer, 0, length);
}
}
}
}
}
/**
* Returns a configuration string with comments reworked as key-value pairs to allow them to be saved when using
* Bukkit's YamlConfiguration class.
*
* @return String with reworked comments.
* @throws IOException
*/
protected String getConfigurationWithReworkedComments() throws IOException {
StringBuilder reworkedConfiguration = new StringBuilder();
try (FileInputStream fileInputStream = new FileInputStream(file);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream, "UTF-8"))) {
numOfComments = 0;
String currentLine;
while ((currentLine = bufferedReader.readLine()) != null) {
if (currentLine.startsWith("#")) {
// Rework comment line so it becomes a standard key-value pair in the configuration file.
// This workaround allows the comment to be saved when using Bukkit's YamlConfiguration class.
reworkedConfiguration.append(currentLine.replace(":", "_COLON_").replace("|", "_VERT_")
.replace("-", "_HYPHEN_").replace(" ", "_SPACE_")
.replaceFirst("#", plugin.getDescription().getName() + "_COMMENT_" + numOfComments + ": "));
numOfComments++;
} else {
reworkedConfiguration.append(currentLine);
}
reworkedConfiguration.append("\n");
}
return reworkedConfiguration.toString();
}
}
/**
* Constructs an instance of the manager. This constructor takes a plugin
* resource name that may be different for the file name used on the server.
*
* @param fileName Name of the file situated in the resource folder of
* the plugin.
* @param pluginResourceName The name of the plugin resource.
* @param plugin The plugin making use of the file.
*/
public FileManager(String fileName, String pluginResourceName, JavaPlugin plugin) {
/**
* Returns the total number of comments in the file. Should be called after the configuration has been parsed by
* {@link #getConfigurationWithReworkedComments()}.
*
* @return Total number of comments in the file.
*/
protected int getNumberOfComments() {
return numOfComments;
}
this.plugin = plugin;
this.pluginResourceName = pluginResourceName;
if (fileName.startsWith("/")) {
/**
* Saves a configuration string into a file.
*
* @param configString The configuration string to save.
* @throws IOException
*/
protected void saveConfiguration(String configString) throws IOException {
String configuration = getConfigurationWithRegeneratedComments(configString);
try (FileOutputStream fileOutputStream = new FileOutputStream(file);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
BufferedWriter bufferedWriter = new BufferedWriter(outputStreamWriter)) {
bufferedWriter.write(configuration);
bufferedWriter.flush();
}
}
file = new File(plugin.getDataFolder() + fileName.replace("/", File.separator));
/**
* Writes the configuration file to disk if it does not exist by copying it from the plugin's resources.
*
* @throws IOException
*/
protected void createConfigurationFileIfNotExists() throws IOException {
file.getParentFile().mkdirs();
if (file.createNewFile()) {
try (OutputStream outputStream = new FileOutputStream(file)) {
InputStream resource = plugin.getResource(pluginResourceName);
if (resource != null) {
int length;
byte[] buf = new byte[1024];
while ((length = resource.read(buf)) > 0) {
outputStream.write(buf, 0, length);
}
}
}
plugin.getLogger().info("Successfully created " + file.getName() + " file.");
}
}
} else {
file = new File(plugin.getDataFolder() + File.separator + fileName.replace("/", File.separator));
}
}
/**
* Performs a backup of the file contained in the plugin's data folder; the
* backup simply makes a copy of the file and adds a .bak extension to it.
*
* @throws IOException
*/
public void backupFile() throws IOException {
File backupFile = new File(plugin.getDataFolder(), file.getName() + ".bak");
// Overwrite previous backup only if a newer version of the file exists.
if (file.lastModified() > backupFile.lastModified() && file.exists()) {
try (FileInputStream inStream = new FileInputStream(file);
FileOutputStream outStream = new FileOutputStream(backupFile))
{
byte[] buffer = new byte[1024];
int length;
while ((length = inStream.read(buffer)) > 0) {
outStream.write(buffer, 0, length);
}
}
}
}
/**
* Returns a configuration string with comments reworked as key-value pairs to
* allow them to be saved when using Bukkit's YamlConfiguration class.
*
* @return String with reworked comments.
* @throws IOException
*/
protected String getConfigurationWithReworkedComments() throws IOException {
StringBuilder reworkedConfiguration = new StringBuilder();
try (FileInputStream fileInputStream = new FileInputStream(file);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream, "UTF-8")))
{
numOfComments = 0;
String currentLine;
while ((currentLine = bufferedReader.readLine()) != null) {
if (currentLine.startsWith("#")) {
// Rework comment line so it becomes a standard key-value pair in the
// configuration file.
// This workaround allows the comment to be saved when using Bukkit's
// YamlConfiguration class.
reworkedConfiguration.append(currentLine.replace(":", "_COLON_").replace("|", "_VERT_")
.replace("-", "_HYPHEN_").replace(" ", "_SPACE_")
.replaceFirst("#", plugin.getPluginMeta().getName() + "_COMMENT_" + numOfComments + ": "));
numOfComments++;
} else {
reworkedConfiguration.append(currentLine);
}
reworkedConfiguration.append("\n");
}
return reworkedConfiguration.toString();
}
}
/**
* Returns the total number of comments in the file. Should be called after the
* configuration has been parsed by
* {@link #getConfigurationWithReworkedComments()}.
*
* @return Total number of comments in the file.
*/
protected int getNumberOfComments() {
return numOfComments;
}
/**
* Saves a configuration string into a file.
*
* @param configString The configuration string to save.
* @throws IOException
*/
protected void saveConfiguration(String configString) throws IOException {
String configuration = getConfigurationWithRegeneratedComments(configString);
try (FileOutputStream fileOutputStream = new FileOutputStream(file);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
BufferedWriter bufferedWriter = new BufferedWriter(outputStreamWriter))
{
bufferedWriter.write(configuration);
bufferedWriter.flush();
}
}
/**
* Writes the configuration file to disk if it does not exist by copying it from
* the plugin's resources.
*
* @throws IOException
*/
protected void createConfigurationFileIfNotExists() throws IOException {
file.getParentFile().mkdirs();
if (file.createNewFile()) {
try (OutputStream outputStream = new FileOutputStream(file)) {
InputStream resource = plugin.getResource(pluginResourceName);
if (resource != null) {
int length;
byte[] buf = new byte[1024];
while ((length = resource.read(buf)) > 0) {
outputStream.write(buf, 0, length);
}
}
}
plugin.getLogger().info("Successfully created " + file.getName() + " file.");
}
}
/**
* Reworks the configuration string in order to regenerate comments.
*
* @param configString The configuration string with reworked comments.
* @return String representing original config file.
*/
private String getConfigurationWithRegeneratedComments(String configString) {
boolean previousLineComment = false;
String[] lines = configString.split("\n");
StringBuilder config = new StringBuilder();
for (String line : lines) {
if (line.startsWith(plugin.getPluginMeta().getName() + "_COMMENT")) {
// Rework comment line so it is converted back to a normal comment.
String comment = ("#" + line.substring(line.indexOf(": ") + 2)).replace("_COLON_", ":")
.replace("_HYPHEN_", "-").replace("_VERT_", "|").replace("_SPACE_", " ");
// No empty line between consecutive comment lines or between a comment and its
// corresponding
// parameters; empty line between parameter and new comment.
if (previousLineComment) {
config.append(comment + "\n");
} else {
config.append("\n" + comment + "\n");
}
previousLineComment = true;
} else {
config.append(line + "\n");
previousLineComment = false;
}
}
return config.toString();
}
/**
* Reworks the configuration string in order to regenerate comments.
*
* @param configString The configuration string with reworked comments.
* @return String representing original config file.
*/
private String getConfigurationWithRegeneratedComments(String configString) {
boolean previousLineComment = false;
String[] lines = configString.split("\n");
StringBuilder config = new StringBuilder();
for (String line : lines) {
if (line.startsWith(plugin.getDescription().getName() + "_COMMENT")) {
// Rework comment line so it is converted back to a normal comment.
String comment = ("#" + line.substring(line.indexOf(": ") + 2)).replace("_COLON_", ":")
.replace("_HYPHEN_", "-").replace("_VERT_", "|").replace("_SPACE_", " ");
// No empty line between consecutive comment lines or between a comment and its corresponding
// parameters; empty line between parameter and new comment.
if (previousLineComment) {
config.append(comment + "\n");
} else {
config.append("\n" + comment + "\n");
}
previousLineComment = true;
} else {
config.append(line + "\n");
previousLineComment = false;
}
}
return config.toString();
}
}
@@ -1,260 +1,325 @@
package com.hm.mcshared.particle;
import com.hm.mcshared.particle.ReflectionUtils.PackageType;
import java.util.UUID;
import org.bukkit.ChatColor;
import net.kyori.adventure.text.TextComponent;
import net.trueog.utilitiesog.UtilitiesOG;
import org.bukkit.entity.Player;
import com.hm.mcshared.particle.ReflectionUtils.PackageType;
/**
* Class used to send fancy messages to the player; can be titles, hoverable chat messages or action bar messages. All
* methods are static and this class cannot be instanciated.
*
* Class used to send fancy messages to the player; can be titles, hoverable
* chat messages or action bar messages. All methods are static and this class
* cannot be instanciated.
*
* @author Pyves
*
*/
public final class FancyMessageSender {
private static final byte CHAT_MESSAGE_BYTE = 1;
private static final byte ACTION_BAR_BYTE = 2;
private static final int MINOR_VERSION_NUMBER = Integer.parseInt(PackageType.getServerVersion().split("_")[1]);
private static final String CLASS_CHAT_BASE_COMPONENT = "IChatBaseComponent";
private static final String CLASS_CRAFT_PLAYER = "CraftPlayer";
private static final String CLASS_ENTITY_PLAYER = "EntityPlayer";
private static final String CLASS_PACKET = "Packet";
private static final String CLASS_PACKET_PLAY_OUT_CHAT = "PacketPlayOutChat";
private static final String CLASS_PACKET_PLAY_OUT_TITLE = "PacketPlayOutTitle";
private static final String CLASS_PLAYER_CONNECTION = "PlayerConnection";
private static final String ENUM_TITLE_ACTION = "EnumTitleAction";
private static final String ENUM_CHAT_MESSAGE_TYPE = "ChatMessageType";
private static final String FIELD_PLAYER_CONNECTION = "playerConnection";
private static final String METHOD_GET_HANDLE = "getHandle";
private static final String METHOD_SEND_PACKET = "sendPacket";
private static final String NESTED_CHAT_SERIALIZER = "ChatSerializer";
private static final String PACKAGE_ENTITY = "entity";
private static final byte CHAT_MESSAGE_BYTE = 1;
private static final byte ACTION_BAR_BYTE = 2;
private static final int MINOR_VERSION_NUMBER = Integer.parseInt(PackageType.getServerVersion().split("_")[1]);
private static final String CLASS_CHAT_BASE_COMPONENT = "IChatBaseComponent";
private static final String CLASS_CRAFT_PLAYER = "CraftPlayer";
private static final String CLASS_ENTITY_PLAYER = "EntityPlayer";
private static final String CLASS_PACKET = "Packet";
private static final String CLASS_PACKET_PLAY_OUT_CHAT = "PacketPlayOutChat";
private static final String CLASS_PACKET_PLAY_OUT_TITLE = "PacketPlayOutTitle";
private static final String CLASS_PLAYER_CONNECTION = "PlayerConnection";
private static final String ENUM_TITLE_ACTION = "EnumTitleAction";
private static final String ENUM_CHAT_MESSAGE_TYPE = "ChatMessageType";
private static final String FIELD_PLAYER_CONNECTION = "playerConnection";
private static final String METHOD_GET_HANDLE = "getHandle";
private static final String METHOD_SEND_PACKET = "sendPacket";
private static final String NESTED_CHAT_SERIALIZER = "ChatSerializer";
private static final String PACKAGE_ENTITY = "entity";
private FancyMessageSender() {
// Not called.
}
private FancyMessageSender() {
/**
* Sends a hoverable message to the player. Only supported in Minecraft 1.8+.
*
* @param player Online player to send the message to.
* @param message The text to display in the chat.
* @param hover The text to display in the hover.
* @param color The color of the hover text.
* @throws Exception
*/
public static void sendHoverableMessage(Player player, String message, String hover, String color) throws Exception {
sendChatPacket(player, constructHoverableMessageJson(message, hover, color), CHAT_MESSAGE_BYTE);
}
// Not called.
}
/**
* Sends a clickable and hoverable message to the player. Only supported in Minecraft 1.8+.
*
* @param player Online player to send the message to.
* @param message The text to display in the chat.
* @param command The command that is entered when clicking on the message.
* @param hover The text to display in the hover.
* @param color The color of the hover text.
* @throws Exception
*/
public static void sendHoverableCommandMessage(Player player, String message, String command, String hover, String color)
throws Exception {
sendChatPacket(player, constructHoverableCommandMessageJson(message, command, hover, color), CHAT_MESSAGE_BYTE);
}
/**
* Sends a hoverable message to the player. Only supported in Minecraft 1.8+.
*
* @param player Online player to send the message to.
* @param message The text to display in the chat.
* @param hover The text to display in the hover.
* @param color The color of the hover text.
* @throws Exception
*/
public static void sendHoverableMessage(Player player, String message, String hover, String color)
throws Exception
{
/**
* Sends an action bar chat message to the player. Only supported in Minecraft 1.8+.
*
* @param player Online player to send the message to.
* @param message The text to display in the action bar.
* @throws Exception
*/
public static void sendActionBarMessage(Player player, String message) throws Exception {
sendChatPacket(player, constructTextJson(message), ACTION_BAR_BYTE);
}
sendChatPacket(player, constructHoverableMessageJson(message, hover, color), CHAT_MESSAGE_BYTE);
/**
* Sends a title and subtitle to the player. Only supported in Minecraft 1.8+.
*
* @param player Online player to send the title and subtitle to.
* @param title The main text that will appear on the player's screen.
* @param subtitle The secondary text that will appear on the player's screen.
* @throws Exception
*/
@SuppressWarnings("deprecation")
public static void sendTitle(Player player, String title, String subtitle) throws Exception {
if (MINOR_VERSION_NUMBER >= 11) {
player.sendTitle(title, subtitle, 10, 70, 20);
} else if (MINOR_VERSION_NUMBER >= 9) {
player.sendTitle(title, subtitle);
} else {
sendTitlePacket(player, constructTextJson(title), constructTextJson(subtitle));
}
}
}
/**
* Sends a title and subtitle packet to the player.
*
* @param player Online player to send the title and subtitle to.
* @param titleJson The title JSON format message to send to the player. See
* http://minecraft.gamepedia.com/Commands#Raw_JSON_text for more information.
* @param subtitleJson The subtitle title JSON format message to send to the player. See
* http://minecraft.gamepedia.com/Commands#Raw_JSON_text for more information.
* @throws ReflectiveOperationException
*/
private static void sendTitlePacket(Player player, String titleJson, String subtitleJson)
throws ReflectiveOperationException {
// Retrieve a CraftPlayer instance and its PlayerConnection instance.
Object craftPlayer = PackageType.CRAFTBUKKIT.getClass(PACKAGE_ENTITY + "." + CLASS_CRAFT_PLAYER).cast(player);
Object craftHandle = PackageType.CRAFTBUKKIT.getClass(PACKAGE_ENTITY + "." + CLASS_CRAFT_PLAYER)
.getMethod(METHOD_GET_HANDLE).invoke(craftPlayer);
Object playerConnection = PackageType.MINECRAFT_SERVER.getClass(CLASS_ENTITY_PLAYER)
.getField(FIELD_PLAYER_CONNECTION).get(craftHandle);
/**
* Sends a clickable and hoverable message to the player. Only supported in
* Minecraft 1.8+.
*
* @param player Online player to send the message to.
* @param message The text to display in the chat.
* @param command The command that is entered when clicking on the message.
* @param hover The text to display in the hover.
* @param color The color of the hover text.
* @throws Exception
*/
public static void sendHoverableCommandMessage(Player player, String message, String command, String hover,
String color) throws Exception
{
Object parsedMainMessage;
Object parsedSubMessage;
Class<?> titleClass;
if (PackageType.getServerVersion().startsWith("1_8_R1")) {
// Prior to version 1.8.3.
parsedMainMessage = PackageType.MINECRAFT_SERVER.getClass(NESTED_CHAT_SERIALIZER)
.getMethod("a", String.class)
.invoke(null, ChatColor.translateAlternateColorCodes('&', titleJson));
parsedSubMessage = PackageType.MINECRAFT_SERVER.getClass(NESTED_CHAT_SERIALIZER)
.getMethod("a", String.class)
.invoke(null, ChatColor.translateAlternateColorCodes('&', subtitleJson));
titleClass = PackageType.MINECRAFT_SERVER.getClass(ENUM_TITLE_ACTION);
} else {
parsedMainMessage = PackageType.MINECRAFT_SERVER
.getClass(CLASS_CHAT_BASE_COMPONENT + "$" + NESTED_CHAT_SERIALIZER).getMethod("a", String.class)
.invoke(null, ChatColor.translateAlternateColorCodes('&', titleJson));
parsedSubMessage = PackageType.MINECRAFT_SERVER
.getClass(CLASS_CHAT_BASE_COMPONENT + "$" + NESTED_CHAT_SERIALIZER).getMethod("a", String.class)
.invoke(null, ChatColor.translateAlternateColorCodes('&', subtitleJson));
titleClass = PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_TITLE + "$" + ENUM_TITLE_ACTION);
}
sendChatPacket(player, constructHoverableCommandMessageJson(message, command, hover, color), CHAT_MESSAGE_BYTE);
// Retrieve parameters for titles and subtitles.
Enum<?> mainTitleEnumValue = null;
Enum<?> subTitleEnumValue = null;
for (Object o : titleClass.getEnumConstants()) {
Enum<?> e = (Enum<?>) o;
if ("TITLE".equalsIgnoreCase(e.name())) {
mainTitleEnumValue = e;
} else if ("SUBTITLE".equalsIgnoreCase(e.name())) {
subTitleEnumValue = e;
}
}
}
Object packetPlayOutChatMainTitle = ReflectionUtils
.getConstructor(PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_TITLE),
PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_TITLE + "$" + ENUM_TITLE_ACTION),
PackageType.MINECRAFT_SERVER.getClass(CLASS_CHAT_BASE_COMPONENT))
.newInstance(mainTitleEnumValue, parsedMainMessage);
/**
* Sends an action bar chat message to the player. Only supported in Minecraft
* 1.8+.
*
* @param player Online player to send the message to.
* @param message The text to display in the action bar.
* @throws Exception
*/
public static void sendActionBarMessage(Player player, String message) throws Exception {
// Send the message packet through the PlayerConnection (title).
PackageType.MINECRAFT_SERVER.getClass(CLASS_PLAYER_CONNECTION)
.getMethod(METHOD_SEND_PACKET, PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET))
.invoke(playerConnection, packetPlayOutChatMainTitle);
sendChatPacket(player, constructTextJson(message), ACTION_BAR_BYTE);
Object packetPlayOutChatSubTitle = ReflectionUtils
.getConstructor(PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_TITLE),
PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_TITLE + "$" + ENUM_TITLE_ACTION),
PackageType.MINECRAFT_SERVER.getClass(CLASS_CHAT_BASE_COMPONENT))
.newInstance(subTitleEnumValue, parsedSubMessage);
}
// Send the message packet through the PlayerConnection (subtitle).
PackageType.MINECRAFT_SERVER.getClass(CLASS_PLAYER_CONNECTION)
.getMethod(METHOD_SEND_PACKET, PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET))
.invoke(playerConnection, packetPlayOutChatSubTitle);
}
/**
* Sends a title and subtitle to the player. Only supported in Minecraft 1.8+.
*
* @param player Online player to send the title and subtitle to.
* @param title The main text that will appear on the player's screen.
* @param subtitle The secondary text that will appear on the player's screen.
* @throws Exception
*/
@SuppressWarnings("deprecation")
public static void sendTitle(Player player, String title, String subtitle) throws Exception {
/**
* Sends a chat packet.
*
* @param player Online player to send the title and subtitle to.
* @param json The message JSON format message to send to the player. See
* http://minecraft.gamepedia.com/Commands#Raw_JSON_text for more information.
* @param type Either 1 (chat mesage) or 2 (action bar message).
* @throws ReflectiveOperationException
*/
private static void sendChatPacket(Player player, String json, byte type) throws ReflectiveOperationException {
// Retrieve a CraftPlayer instance and its PlayerConnection instance.
Object craftPlayer = PackageType.CRAFTBUKKIT.getClass(PACKAGE_ENTITY + "." + CLASS_CRAFT_PLAYER).cast(player);
Object craftHandle = PackageType.CRAFTBUKKIT.getClass(PACKAGE_ENTITY + "." + CLASS_CRAFT_PLAYER)
.getMethod(METHOD_GET_HANDLE).invoke(craftPlayer);
Object playerConnection = PackageType.MINECRAFT_SERVER.getClass(CLASS_ENTITY_PLAYER)
.getField(FIELD_PLAYER_CONNECTION).get(craftHandle);
if (MINOR_VERSION_NUMBER >= 11) {
Object parsedMessage;
if (PackageType.getServerVersion().startsWith("1_8_R1")) {
// Prior to version 1.8.3.
parsedMessage = PackageType.MINECRAFT_SERVER.getClass(NESTED_CHAT_SERIALIZER).getMethod("a", String.class)
.invoke(null, ChatColor.translateAlternateColorCodes('&', json));
} else {
parsedMessage = Class
.forName(PackageType.MINECRAFT_SERVER + "." + CLASS_CHAT_BASE_COMPONENT + "$" + NESTED_CHAT_SERIALIZER)
.getMethod("a", String.class)
.invoke(null, ChatColor.translateAlternateColorCodes('&', json));
}
player.sendTitle(title, subtitle, 10, 70, 20);
Object packetPlayOutChat;
if (MINOR_VERSION_NUMBER < 12) {
packetPlayOutChat = PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_CHAT)
.getConstructor(PackageType.MINECRAFT_SERVER.getClass(CLASS_CHAT_BASE_COMPONENT), byte.class)
.newInstance(parsedMessage, type);
} else {
// New method uses the ChatMessageType enum rather than a byte.
Class<?> chatMessageTypeClass = PackageType.MINECRAFT_SERVER.getClass(ENUM_CHAT_MESSAGE_TYPE);
Enum<?> chatType = null;
for (Object chatMessageType : chatMessageTypeClass.getEnumConstants()) {
Enum<?> e = (Enum<?>) chatMessageType;
if ("SYSTEM".equalsIgnoreCase(e.name()) && type == CHAT_MESSAGE_BYTE
|| "GAME_INFO".equalsIgnoreCase(e.name()) && type == ACTION_BAR_BYTE) {
chatType = e;
break;
}
}
// Constructor signature Minecraft 1.7 - 1.15:
// public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype)
// Constructor signature Minecraft 1.16+:
// public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid)
if (MINOR_VERSION_NUMBER < 16) {
packetPlayOutChat = PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_CHAT)
.getConstructor(PackageType.MINECRAFT_SERVER.getClass(CLASS_CHAT_BASE_COMPONENT),
chatMessageTypeClass)
.newInstance(parsedMessage, chatType);
} else {
packetPlayOutChat = PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_CHAT)
.getConstructor(PackageType.MINECRAFT_SERVER.getClass(CLASS_CHAT_BASE_COMPONENT),
chatMessageTypeClass, UUID.class)
.newInstance(parsedMessage, chatType, player.getUniqueId());
}
}
} else if (MINOR_VERSION_NUMBER >= 9) {
// Send the message packet through the PlayerConnection.
PackageType.MINECRAFT_SERVER.getClass(CLASS_PLAYER_CONNECTION)
.getMethod(METHOD_SEND_PACKET, PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET))
.invoke(playerConnection, packetPlayOutChat);
}
player.sendTitle(title, subtitle);
private static String constructTextJson(String text) {
return "{\"text\":\"" + text.replace("\"", "\\\"") + "\"}";
}
} else {
private static String constructHoverableMessageJson(String message, String hover, String color) {
return "{\"text\":\"" + message.replace("\"", "\\\"") + "\","
+ "\"hoverEvent\":{\"action\":\"show_text\",\"value\":[{\"text\":\""
+ hover.replace("\"", "\\\"") + "\",\"color\":\"" + color + "\"}]}}";
}
sendTitlePacket(player, constructTextJson(title), constructTextJson(subtitle));
}
}
/**
* Sends a title and subtitle packet to the player.
*
* @param player Online player to send the title and subtitle to.
* @param titleJson The title JSON format message to send to the player. See
* http://minecraft.gamepedia.com/Commands#Raw_JSON_text for
* more information.
* @param subtitleJson The subtitle title JSON format message to send to the
* player. See
* http://minecraft.gamepedia.com/Commands#Raw_JSON_text for
* more information.
* @throws ReflectiveOperationException
*/
private static void sendTitlePacket(Player player, String titleJson, String subtitleJson)
throws ReflectiveOperationException
{
// Retrieve a CraftPlayer instance and its PlayerConnection instance.
Object craftPlayer = PackageType.CRAFTBUKKIT.getClass(PACKAGE_ENTITY + "." + CLASS_CRAFT_PLAYER).cast(player);
Object craftHandle = PackageType.CRAFTBUKKIT.getClass(PACKAGE_ENTITY + "." + CLASS_CRAFT_PLAYER)
.getMethod(METHOD_GET_HANDLE).invoke(craftPlayer);
Object playerConnection = PackageType.MINECRAFT_SERVER.getClass(CLASS_ENTITY_PLAYER)
.getField(FIELD_PLAYER_CONNECTION).get(craftHandle);
Object parsedMainMessage;
Object parsedSubMessage;
Class<?> titleClass;
if (PackageType.getServerVersion().startsWith("1_8_R1")) {
// Prior to version 1.8.3.
parsedMainMessage = PackageType.MINECRAFT_SERVER.getClass(NESTED_CHAT_SERIALIZER)
.getMethod("a", String.class).invoke(null, UtilitiesOG.trueogExpand(titleJson, player));
parsedSubMessage = PackageType.MINECRAFT_SERVER.getClass(NESTED_CHAT_SERIALIZER)
.getMethod("a", String.class).invoke(null, UtilitiesOG.trueogExpand(subtitleJson, player));
titleClass = PackageType.MINECRAFT_SERVER.getClass(ENUM_TITLE_ACTION);
} else {
parsedMainMessage = PackageType.MINECRAFT_SERVER
.getClass(CLASS_CHAT_BASE_COMPONENT + "$" + NESTED_CHAT_SERIALIZER).getMethod("a", String.class)
.invoke(null, UtilitiesOG.trueogExpand(titleJson, player));
parsedSubMessage = PackageType.MINECRAFT_SERVER
.getClass(CLASS_CHAT_BASE_COMPONENT + "$" + NESTED_CHAT_SERIALIZER).getMethod("a", String.class)
.invoke(null, UtilitiesOG.trueogExpand(subtitleJson, player));
titleClass = PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_TITLE + "$" + ENUM_TITLE_ACTION);
}
// Retrieve parameters for titles and subtitles.
Enum<?> mainTitleEnumValue = null;
Enum<?> subTitleEnumValue = null;
for (Object o : titleClass.getEnumConstants()) {
Enum<?> e = (Enum<?>) o;
if ("TITLE".equalsIgnoreCase(e.name())) {
mainTitleEnumValue = e;
} else if ("SUBTITLE".equalsIgnoreCase(e.name())) {
subTitleEnumValue = e;
}
}
Object packetPlayOutChatMainTitle = ReflectionUtils
.getConstructor(PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_TITLE),
PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_TITLE + "$" + ENUM_TITLE_ACTION),
PackageType.MINECRAFT_SERVER.getClass(CLASS_CHAT_BASE_COMPONENT))
.newInstance(mainTitleEnumValue, parsedMainMessage);
// Send the message packet through the PlayerConnection (title).
PackageType.MINECRAFT_SERVER.getClass(CLASS_PLAYER_CONNECTION)
.getMethod(METHOD_SEND_PACKET, PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET))
.invoke(playerConnection, packetPlayOutChatMainTitle);
Object packetPlayOutChatSubTitle = ReflectionUtils
.getConstructor(PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_TITLE),
PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_TITLE + "$" + ENUM_TITLE_ACTION),
PackageType.MINECRAFT_SERVER.getClass(CLASS_CHAT_BASE_COMPONENT))
.newInstance(subTitleEnumValue, parsedSubMessage);
// Send the message packet through the PlayerConnection (subtitle).
PackageType.MINECRAFT_SERVER.getClass(CLASS_PLAYER_CONNECTION)
.getMethod(METHOD_SEND_PACKET, PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET))
.invoke(playerConnection, packetPlayOutChatSubTitle);
}
/**
* Sends a chat packet.
*
* @param player Online player to send the title and subtitle to.
* @param json The message JSON format message to send to the player. See
* http://minecraft.gamepedia.com/Commands#Raw_JSON_text for more
* information.
* @param type Either 1 (chat mesage) or 2 (action bar message).
* @throws ReflectiveOperationException
*/
private static void sendChatPacket(Player player, String json, byte type) throws ReflectiveOperationException {
// Retrieve a CraftPlayer instance and its PlayerConnection instance.
Object craftPlayer = PackageType.CRAFTBUKKIT.getClass(PACKAGE_ENTITY + "." + CLASS_CRAFT_PLAYER).cast(player);
Object craftHandle = PackageType.CRAFTBUKKIT.getClass(PACKAGE_ENTITY + "." + CLASS_CRAFT_PLAYER)
.getMethod(METHOD_GET_HANDLE).invoke(craftPlayer);
Object playerConnection = PackageType.MINECRAFT_SERVER.getClass(CLASS_ENTITY_PLAYER)
.getField(FIELD_PLAYER_CONNECTION).get(craftHandle);
Object parsedMessage;
if (PackageType.getServerVersion().startsWith("1_8_R1")) {
// Prior to version 1.8.3.
parsedMessage = PackageType.MINECRAFT_SERVER.getClass(NESTED_CHAT_SERIALIZER).getMethod("a", String.class)
.invoke(null, UtilitiesOG.trueogExpand(json, player));
} else {
TextComponent textComponent = UtilitiesOG.trueogExpand(json, player);
parsedMessage = textComponent;
}
Object packetPlayOutChat;
if (MINOR_VERSION_NUMBER < 12) {
packetPlayOutChat = PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_CHAT)
.getConstructor(PackageType.MINECRAFT_SERVER.getClass(CLASS_CHAT_BASE_COMPONENT), byte.class)
.newInstance(parsedMessage, type);
} else {
// New method uses the ChatMessageType enum rather than a byte.
Class<?> chatMessageTypeClass = PackageType.MINECRAFT_SERVER.getClass(ENUM_CHAT_MESSAGE_TYPE);
Enum<?> chatType = null;
for (Object chatMessageType : chatMessageTypeClass.getEnumConstants()) {
Enum<?> e = (Enum<?>) chatMessageType;
if ("SYSTEM".equalsIgnoreCase(e.name()) && type == CHAT_MESSAGE_BYTE
|| "GAME_INFO".equalsIgnoreCase(e.name()) && type == ACTION_BAR_BYTE)
{
chatType = e;
break;
}
}
// Constructor signature Minecraft 1.7 - 1.15:
// public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent,
// ChatMessageType chatmessagetype)
// Constructor signature Minecraft 1.16+:
// public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent,
// ChatMessageType chatmessagetype, UUID
// uuid)
if (MINOR_VERSION_NUMBER < 16) {
packetPlayOutChat = PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_CHAT)
.getConstructor(PackageType.MINECRAFT_SERVER.getClass(CLASS_CHAT_BASE_COMPONENT),
chatMessageTypeClass)
.newInstance(parsedMessage, chatType);
} else {
packetPlayOutChat = PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET_PLAY_OUT_CHAT)
.getConstructor(PackageType.MINECRAFT_SERVER.getClass(CLASS_CHAT_BASE_COMPONENT),
chatMessageTypeClass, UUID.class)
.newInstance(parsedMessage, chatType, player.getUniqueId());
}
}
// Send the message packet through the PlayerConnection.
PackageType.MINECRAFT_SERVER.getClass(CLASS_PLAYER_CONNECTION)
.getMethod(METHOD_SEND_PACKET, PackageType.MINECRAFT_SERVER.getClass(CLASS_PACKET))
.invoke(playerConnection, packetPlayOutChat);
}
private static String constructTextJson(String text) {
return "{\"text\":\"" + text.replace("\"", "\\\"") + "\"}";
}
private static String constructHoverableMessageJson(String message, String hover, String color) {
return "{\"text\":\"" + message.replace("\"", "\\\"") + "\","
+ "\"hoverEvent\":{\"action\":\"show_text\",\"value\":[{\"text\":\"" + hover.replace("\"", "\\\"")
+ "\",\"color\":\"" + color + "\"}]}}";
}
private static String constructHoverableCommandMessageJson(String message, String command, String hover,
String color)
{
return "{\"text\":\"" + message.replace("\"", "\\\"") + "\","
+ "\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"" + command + "\"},"
+ "\"hoverEvent\":{\"action\":\"show_text\",\"value\":[{\"text\":\"" + hover.replace("\"", "\\\"")
+ "\",\"color\":\"" + color + "\"}]}}";
}
private static String constructHoverableCommandMessageJson(String message, String command, String hover, String color) {
return "{\"text\":\"" + message.replace("\"", "\\\"") + "\","
+ "\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"" + command + "\"},"
+ "\"hoverEvent\":{\"action\":\"show_text\",\"value\":[{\"text\":\""
+ hover.replace("\"", "\\\"") + "\",\"color\":\"" + color + "\"}]}}";
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,193 +0,0 @@
package com.hm.mcshared.update;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
/**
* Class used to check for newer versions of a plugin by retrieving a version tag in a pom.xml file. For instance
* versions 2.0, 1.2 and 1.1.1 are all considered newer than 1.1.
* <p>
* If a newer version is available, the information will be logged in the server's console and a message will be sent
* when players with a specific permission join the game.
* <p>
* This class implements the org.bukkit.event.Listener class. To use it, simply create an instance of this class and
* register events to the server's PluginManager (for instance in your plugin class extending JavaPlugin:
* getServer().getPluginManager().registerEvents(updateChecker, this);).
*
* @author Pyves
*/
public class UpdateChecker implements Listener {
private final JavaPlugin plugin;
private final String pomLink;
private final String downloadLink;
private final String notificationPermission;
private final String chatHeader;
// Marked as volatile to ensure that once the updateCheckerFutureTask is done, the version is visible to the main
// thread of execution.
private volatile String version;
private Boolean updateNeeded = null;
private FutureTask<Boolean> updateCheckerFutureTask;
/**
* Creates an instance of the UpdateChecker class.
*
* @param plugin The plugin involved in the version checking.
* @param pomLink The link to the plugin's pom.xml. For instance
* https://raw.githubusercontent.com/PyvesB/AdvancedAchievements/master/pom.xml can be used.
* @param notificationPermission Only players with this permissions will be notified in game.
* @param chatHeader Header of the message to display in the chat when notifying that an update is available.
* @param downloadLink The link from which the plugin can be downloaded; will be displayed in the server's console
* and in game to users with notificationPermission.
*/
public UpdateChecker(JavaPlugin plugin, String pomLink, String notificationPermission, String chatHeader,
String downloadLink) {
this.plugin = plugin;
this.pomLink = pomLink;
this.notificationPermission = notificationPermission;
this.chatHeader = chatHeader;
this.downloadLink = downloadLink;
}
/**
* Listens to PlayerJoinEvents and informs players with a specific permission that an update is available.
*
* @param event Event sent to this listener method.
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event) {
// Check if OP to display new version message if needed.
if (isUpdateNeeded() && event.getPlayer().hasPermission(notificationPermission)) {
event.getPlayer().sendMessage(chatHeader + plugin.getDescription().getName() + " update available: v"
+ version + ". Download at " + downloadLink);
}
}
/**
* Launches a new thread to asynchronously check whether an update is available.
*/
public void launchUpdateCheckerTask() {
updateCheckerFutureTask = new FutureTask<>(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return checkForUpdate();
}
});
// Run the FutureTask in a new thread.
new Thread(updateCheckerFutureTask).start();
}
/**
* Returns whether the plugin needs to be updated. Will always return false if launchUpdateCheckerTask has not yet
* been called or the asynchronous call has not yet completed.
*
* @return true is an update is available, false otherwise.
*/
public boolean isUpdateNeeded() {
// Completion of the FutureTask has not yet been checked.
if (updateNeeded == null) {
if (updateCheckerFutureTask.isDone()) {
try {
// Retrieve result of the FutureTask.
updateNeeded = updateCheckerFutureTask.get();
} catch (InterruptedException | ExecutionException e) {
// Error during execution; assume that no updates are available.
updateNeeded = false;
plugin.getLogger()
.severe("Error while checking for " + plugin.getDescription().getName() + " update.");
}
} else {
// FutureTask not yet completed; indicate that no updates are available. If an OP joins before the task
// completes, he will not be notified; this is both an unlikely and non critical scenario.
return false;
}
}
return updateNeeded;
}
/**
* Returns the version tag of the plugin parsed from the specified pom.xml. Will be null if launchUpdateCheckerTask
* has not yet been called or the asynchronous call has not yet completed.
*
* @return The version tag of the plugin parsed from the specified pom.xml.
*/
public String getVersion() {
return version;
}
/**
* Checks if a new version of the plugin is available, and logs in the server's console if a new version is found.
*
* @return True if an update is available, false otherwise.
*
* @throws ParserConfigurationException
* @throws IOException
* @throws SAXException
*/
private boolean checkForUpdate() throws SAXException, IOException, ParserConfigurationException {
plugin.getLogger().info("Checking for plugin update...");
Document document = null;
URL filesFeed = new URL(pomLink);
try (InputStream pomInput = filesFeed.openConnection().getInputStream()) {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(pomInput);
}
// Retrieve version information.
version = document.getElementsByTagName("version").item(0).getTextContent();
if (version.equals(plugin.getDescription().getVersion())) {
return false;
}
// Version of current plugin.
String[] pluginVersion = plugin.getDescription().getVersion().split("\\.");
// Version of the pom.xml file.
String[] onlineVersion = version.split("\\.");
// Compare version numbers.
for (int i = 0; i < Math.min(pluginVersion.length, onlineVersion.length); i++) {
if (Integer.parseInt(pluginVersion[i]) > Integer.parseInt(onlineVersion[i])) {
return false;
} else if (Integer.parseInt(pluginVersion[i]) < Integer.parseInt(onlineVersion[i])) {
logUpdate();
return true;
}
}
// Both versions have the same prefix; additional length check (for instance pluginVersion = 2.2 and
// onlineVersion = 2.2.1).
if (pluginVersion.length < onlineVersion.length) {
logUpdate();
return true;
}
return false;
}
/**
* Logs in the server's console if a new version is found. The new version number and download links are printed.
*/
private void logUpdate() {
plugin.getLogger().warning("Update available: v" + version + "! Download at " + downloadLink);
}
}