Initial release
This commit is contained in:
1 parent
ddea8a70dc
commit
98a6d4ebbe
17 files changed
+1137
-172
No files matched your search
@@ -1,8 +1,8 @@
|
||||
[placeholder-page]: https://helpch.at/placeholders#server
|
||||
[buildImg]: http://ci.extendedclip.com/buildStatus/icon?job=Server-Expansion
|
||||
[build]: http://ci.extendedclip.com/job/Server-Expansion/
|
||||
|
||||
# Server-Expansion
|
||||
[buildImg]: http://ci.extendedclip.com/buildStatus/icon?job=Server-PAPI
|
||||
[build]: http://ci.extendedclip.com/job/Server-PAPI/
|
||||
|
||||
# Server-PAPI
|
||||
[![buildImg]][build]
|
||||
|
||||
Adds server-related placeholders.
|
||||
|
||||
+87
-19
@@ -1,37 +1,105 @@
|
||||
/* This is free and unencumbered software released into the public domain */
|
||||
|
||||
/* ------------------------------ Plugins ------------------------------ */
|
||||
plugins {
|
||||
`java-library`
|
||||
id("com.gradleup.shadow") version "8.3.0"
|
||||
id("java")
|
||||
id("java-library")
|
||||
id("com.diffplug.spotless") version "8.1.0"
|
||||
id("com.gradleup.shadow") version "8.3.9"
|
||||
id("checkstyle")
|
||||
eclipse
|
||||
}
|
||||
|
||||
/* --------------------------- JDK ------------------------------------- */
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
vendor.set(JvmVendorSpec.GRAAL_VM)
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------- Metadata ------------------------------ */
|
||||
group = "at.helpch.placeholderapi.expansion"
|
||||
|
||||
version = "2.7.3"
|
||||
|
||||
/* ----------------------------- Resources ----------------------------- */
|
||||
tasks.named<ProcessResources>("processResources") { from("LICENSE") { into("/") } }
|
||||
|
||||
/* ---------------------------- Repos ---------------------------------- */
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||
gradlePluginPortal()
|
||||
maven { url = uri("https://repo.purpurmc.org/snapshots") }
|
||||
maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") }
|
||||
}
|
||||
|
||||
/* ---------------------- Java project deps ---------------------------- */
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
|
||||
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT")
|
||||
compileOnly("me.clip:placeholderapi:2.11.7")
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
manifest {
|
||||
attributes["Implementation-Title"] = "server"
|
||||
attributes["Implementation-Version"] = project.version
|
||||
}
|
||||
}
|
||||
apply(from = "eclipse.gradle.kts")
|
||||
|
||||
java {
|
||||
disableAutoTargetJvm()
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
/* ---------------------- Reproducible jars ---------------------------- */
|
||||
tasks.withType<AbstractArchiveTask>().configureEach {
|
||||
isPreserveFileTimestamps = false
|
||||
isReproducibleFileOrder = true
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName.set("PAPI-Expansion-Server-${project.version}.jar")
|
||||
/* ----------------------------- Jar ----------------------------------- */
|
||||
tasks.jar {
|
||||
archiveClassifier.set("part")
|
||||
manifest {
|
||||
attributes["Implementation-Title"] = "Server-PAPI"
|
||||
attributes["Implementation-Version"] = project.version
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------- Shadow -------------------------------- */
|
||||
tasks.shadowJar {
|
||||
archiveClassifier.set("")
|
||||
archiveFileName.set("Server-PAPI-${project.version}.jar")
|
||||
manifest {
|
||||
attributes["Implementation-Title"] = "Server-PAPI"
|
||||
attributes["Implementation-Version"] = project.version
|
||||
}
|
||||
minimize()
|
||||
}
|
||||
|
||||
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) }
|
||||
|
||||
/* --------------------------- Javac opts ------------------------------- */
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add("-parameters")
|
||||
options.compilerArgs.add("-Xlint:deprecation")
|
||||
options.encoding = "UTF-8"
|
||||
options.isFork = true
|
||||
}
|
||||
|
||||
/* ----------------------------- Auto Formatting ------------------------ */
|
||||
spotless {
|
||||
java {
|
||||
eclipse().configFile("config/formatter/eclipse-java-formatter.xml")
|
||||
leadingTabsToSpaces()
|
||||
removeUnusedImports()
|
||||
}
|
||||
kotlinGradle {
|
||||
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) }
|
||||
target("build.gradle.kts", "settings.gradle.kts")
|
||||
}
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.18.1"
|
||||
configFile = file("config/checkstyle/checkstyle.xml")
|
||||
isIgnoreFailures = true
|
||||
isShowViolations = true
|
||||
}
|
||||
|
||||
tasks.named("compileJava") { dependsOn("spotlessApply") }
|
||||
|
||||
tasks.named("spotlessCheck") { dependsOn("spotlessApply") }
|
||||
@@ -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*"Not yet implemented"\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="(?<!\w)fail\s*\(\s*"Not yet implemented"\s*\)\s*;"/>
|
||||
<property name="message" value="Remove placeholder fail() and implement the test."/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
|
||||
@@ -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>
|
||||
@@ -0,0 +1,158 @@
|
||||
/* This is free and unencumbered software released into the public domain */
|
||||
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.plugins.ide.eclipse.model.EclipseModel
|
||||
import java.nio.file.Files
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.transform.OutputKeys
|
||||
import javax.xml.transform.TransformerFactory
|
||||
import javax.xml.transform.dom.DOMSource
|
||||
import javax.xml.transform.stream.StreamResult
|
||||
|
||||
val sourcePluginProjects =
|
||||
configurations
|
||||
.getByName("compileClasspath")
|
||||
.allDependencies
|
||||
.filterIsInstance<ProjectDependency>()
|
||||
.map { it.path }
|
||||
.filter { it.startsWith(":libs:") }
|
||||
.distinct()
|
||||
val sourcePluginProjectNames = sourcePluginProjects.map { it.substringAfterLast(":") }.toSet()
|
||||
sourcePluginProjects.forEach { evaluationDependsOn(it) }
|
||||
|
||||
val ideLibs: Configuration by
|
||||
configurations.creating {
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
}
|
||||
|
||||
configure<EclipseModel> {
|
||||
project {
|
||||
name = "${rootProject.name}-Plugin"
|
||||
}
|
||||
classpath {
|
||||
plusConfigurations.add(ideLibs)
|
||||
}
|
||||
}
|
||||
|
||||
val ideLibDir = layout.buildDirectory.dir("ide-libs")
|
||||
val hashRegex = Regex("-[0-9a-fA-F]{10}(?=\\.jar$)") // Black magic.
|
||||
|
||||
val copyTasks = mutableListOf<TaskProvider<Copy>>()
|
||||
|
||||
sourcePluginProjects.forEach { path ->
|
||||
val sub = project(path)
|
||||
val archiveTaskName = if ("shadowJar" in sub.tasks.names) "shadowJar" else "jar"
|
||||
val archiveTask = sub.tasks.named<Jar>(archiveTaskName)
|
||||
val copyTask =
|
||||
tasks.register<Copy>("ideCopy${sub.name.replaceFirstChar(Char::titlecase)}") {
|
||||
dependsOn(archiveTask)
|
||||
from(archiveTask.flatMap { it.archiveFile })
|
||||
into(ideLibDir)
|
||||
rename { it.replace(hashRegex, "") } // Remove git commit hash from jarfile.
|
||||
}
|
||||
copyTasks += copyTask
|
||||
}
|
||||
|
||||
/* Ensure the jars exist before .classpath is generated */
|
||||
tasks.named("eclipseClasspath").configure { dependsOn(copyTasks) }
|
||||
|
||||
/* Supply those jars to the ideLibs configuration (after evaluation) */
|
||||
afterEvaluate { dependencies { add("ideLibs", fileTree(ideLibDir) { include("*.jar") }) } }
|
||||
|
||||
val injectIdeLibs =
|
||||
tasks.register("injectIdeLibs") {
|
||||
dependsOn("eclipse") // run after all eclipse files are generated
|
||||
doLast {
|
||||
val cpFile = file(".classpath")
|
||||
if (!cpFile.exists()) return@doLast
|
||||
|
||||
val jars = fileTree(ideLibDir.get()) { include("*.jar") }.files.sortedBy { it.name }
|
||||
if (jars.isEmpty()) return@doLast
|
||||
|
||||
// Parse DOM
|
||||
val dbf = DocumentBuilderFactory.newInstance()
|
||||
val doc = dbf.newDocumentBuilder().parse(cpFile)
|
||||
val root = doc.documentElement
|
||||
|
||||
// Helper to see if an entry already exists
|
||||
fun exists(path: String): Boolean =
|
||||
root.getElementsByTagName("classpathentry").let { list ->
|
||||
(0 until list.length).any { i ->
|
||||
val n = list.item(i)
|
||||
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
|
||||
val p = n.attributes?.getNamedItem("path")?.nodeValue
|
||||
kind == "lib" && p == path
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any entry that points to ide-libs dir or unresolved :libs: project refs.
|
||||
val toRemove = mutableListOf<org.w3c.dom.Node>()
|
||||
val list = root.getElementsByTagName("classpathentry")
|
||||
val dirPath = ideLibDir.get().asFile.absolutePath
|
||||
for (i in 0 until list.length) {
|
||||
val n = list.item(i)
|
||||
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
|
||||
val p = n.attributes?.getNamedItem("path")?.nodeValue ?: ""
|
||||
val isIdeLibEntry = kind == "lib" && (p == dirPath || p.startsWith("$dirPath/"))
|
||||
val sourceProjectPath = p.removePrefix("/")
|
||||
val isHalfImportedSourceModule = kind == "src" && p.startsWith("/libs:")
|
||||
val isSourcePluginModule = kind == "src" && sourceProjectPath in sourcePluginProjectNames
|
||||
if (isIdeLibEntry || isHalfImportedSourceModule || isSourcePluginModule) {
|
||||
toRemove += n
|
||||
}
|
||||
}
|
||||
toRemove.forEach { root.removeChild(it) }
|
||||
|
||||
// Append our jar entries LAST
|
||||
jars.forEach { f ->
|
||||
val abs = f.absolutePath
|
||||
if (!exists(abs)) {
|
||||
val entry = doc.createElement("classpathentry")
|
||||
entry.setAttribute("kind", "lib")
|
||||
entry.setAttribute("path", abs)
|
||||
root.appendChild(entry)
|
||||
}
|
||||
}
|
||||
|
||||
// Write back pretty
|
||||
val tf =
|
||||
TransformerFactory.newInstance().newTransformer().apply {
|
||||
setOutputProperty(OutputKeys.INDENT, "yes")
|
||||
setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "1")
|
||||
setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no")
|
||||
setOutputProperty(OutputKeys.ENCODING, "UTF-8")
|
||||
}
|
||||
Files.newBufferedWriter(cpFile.toPath()).use { w -> tf.transform(DOMSource(doc), StreamResult(w)) }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("eclipse").configure { finalizedBy(injectIdeLibs) }
|
||||
|
||||
val eclipseModel = extensions.getByType<EclipseModel>()
|
||||
|
||||
fun Project.addResolvableEclipseConfigs() {
|
||||
val jarAttr =
|
||||
objects.named(org.gradle.api.attributes.LibraryElements::class, org.gradle.api.attributes.LibraryElements.JAR)
|
||||
val apiAttr = objects.named(org.gradle.api.attributes.Usage::class, org.gradle.api.attributes.Usage.JAVA_API)
|
||||
|
||||
val compileOnlyRes =
|
||||
configurations.create("eclipseCompileOnly") {
|
||||
extendsFrom(configurations.getByName("compileOnly"))
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
|
||||
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
|
||||
}
|
||||
val compileOnlyApiRes =
|
||||
configurations.create("eclipseCompileOnlyApi") {
|
||||
extendsFrom(configurations.getByName("compileOnlyApi"))
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
|
||||
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
|
||||
}
|
||||
eclipseModel.classpath.plusConfigurations.addAll(listOf(compileOnlyRes, compileOnlyApiRes))
|
||||
}
|
||||
|
||||
addResolvableEclipseConfigs()
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# 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/.
|
||||
@@ -84,7 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
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
|
||||
@@ -112,7 +114,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -203,7 +205,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * 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.
|
||||
@@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+4
-2
@@ -13,6 +13,8 @@
|
||||
@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 ##########################################################################
|
||||
@@ -68,11 +70,11 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%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
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'Server-Expansion'
|
||||
+1
-1
@@ -1 +1 @@
|
||||
rootProject.name = "PAPI-Expansion-Server"
|
||||
rootProject.name = "Server-PAPI"
|
||||
@@ -31,16 +31,15 @@ import java.util.function.ToIntFunction;
|
||||
|
||||
public final class ServerExpansion extends PlaceholderExpansion implements Cacheable, Configurable {
|
||||
|
||||
private final Cache<String, Integer> cache = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(1, TimeUnit.MINUTES)
|
||||
.build();
|
||||
private final Cache<String, Integer> cache = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
private final Runtime runtime = Runtime.getRuntime();
|
||||
|
||||
/**
|
||||
* Constant that represents how many bytes are in a mebibyte
|
||||
* <br/>
|
||||
* Required for the {@code ram_} placeholders, as the values provided by the system are in bytes
|
||||
* Constant that represents how many bytes are in a mebibyte <br/>
|
||||
* Required for the {@code ram_} placeholders, as the values provided by the
|
||||
* system are in bytes
|
||||
*/
|
||||
private final int MiB = 1_048_576;
|
||||
|
||||
@@ -53,57 +52,59 @@ public final class ServerExpansion extends PlaceholderExpansion implements Cache
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
|
||||
return "server";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
|
||||
return "HelpChat";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
|
||||
return getClass().getPackage().getImplementationVersion();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRegister() {
|
||||
|
||||
this.serverName = getString("server_name", "A Minecraft Server");
|
||||
this.tpsFormatter = new TpsFormatter(
|
||||
getString("tps_color.low", "&c"),
|
||||
getString("tps_color.medium", "&e"),
|
||||
getString("tps_color.high", "&a")
|
||||
);
|
||||
this.tpsFormatter = new TpsFormatter(getString("tps_color.low", "&c"), getString("tps_color.medium", "&e"),
|
||||
getString("tps_color.high", "&a"));
|
||||
this.timeFormatter = new TimeFormatter(
|
||||
Locale.forLanguageTag(this.getString("time.locale", Locale.getDefault().toLanguageTag())),
|
||||
ZoneId.of(this.getString("time.zone", ZoneId.systemDefault().getId())),
|
||||
Optional.ofNullable(getConfigSection("time.suffix")).map(section -> section.getValues(false)).orElseGet(HashMap::new)
|
||||
);
|
||||
Locale.forLanguageTag(this.getString("time.locale", Locale.getDefault().toLanguageTag())),
|
||||
ZoneId.of(this.getString("time.zone", ZoneId.systemDefault().getId())),
|
||||
Optional.ofNullable(getConfigSection("time.suffix")).map(section -> section.getValues(false))
|
||||
.orElseGet(HashMap::new));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
cache.invalidateAll();
|
||||
timeFormatter = null;
|
||||
tpsFormatter = null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDefaults() {
|
||||
return ImmutableMap.<String, Object>builder()
|
||||
.put("server_name", "A Minecraft Server")
|
||||
.put("time.locale", Locale.getDefault().toLanguageTag())
|
||||
.put("time.zone", ZoneId.systemDefault().getId())
|
||||
.put("time.suffix.week", "w")
|
||||
.put("time.suffix.day", "d")
|
||||
.put("time.suffix.hour", "h")
|
||||
.put("time.suffix.minute", "m")
|
||||
.put("time.suffix.second", "s")
|
||||
.put("tps_color.high", "&a")
|
||||
.put("tps_color.medium", "&e")
|
||||
.put("tps_color.low", "&c")
|
||||
.build();
|
||||
|
||||
return ImmutableMap.<String, Object>builder().put("server_name", "A Minecraft Server")
|
||||
.put("time.locale", Locale.getDefault().toLanguageTag())
|
||||
.put("time.zone", ZoneId.systemDefault().getId()).put("time.suffix.week", "w")
|
||||
.put("time.suffix.day", "d").put("time.suffix.hour", "h").put("time.suffix.minute", "m")
|
||||
.put("time.suffix.second", "s").put("tps_color.high", "&a").put("tps_color.medium", "&e")
|
||||
.put("tps_color.low", "&c").build();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,10 +114,9 @@ public final class ServerExpansion extends PlaceholderExpansion implements Cache
|
||||
* @return sum
|
||||
*/
|
||||
private int getFromAllWorlds(@NotNull final ToIntFunction<? super World> function) {
|
||||
return Bukkit.getWorlds()
|
||||
.stream()
|
||||
.mapToInt(function)
|
||||
.sum();
|
||||
|
||||
return Bukkit.getWorlds().stream().mapToInt(function).sum();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,71 +127,97 @@ public final class ServerExpansion extends PlaceholderExpansion implements Cache
|
||||
* @return value if found otherwise empty
|
||||
*/
|
||||
private @NotNull String getFromCache(@NotNull final String key, @NotNull final Callable<Integer> callable) {
|
||||
|
||||
try {
|
||||
|
||||
return String.valueOf(cache.get(key, callable));
|
||||
|
||||
} catch (ExecutionException e) {
|
||||
|
||||
Logging.error(e, "Could not get key \"{0}\" from cache", key);
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a {@code boolean} as {@link PlaceholderAPIPlugin#booleanTrue()} or {@link PlaceholderAPIPlugin#booleanFalse()}
|
||||
* Format a {@code boolean} as {@link PlaceholderAPIPlugin#booleanTrue()} or
|
||||
* {@link PlaceholderAPIPlugin#booleanFalse()}
|
||||
*
|
||||
* @param bool boolean
|
||||
* @return {@link PlaceholderAPIPlugin#booleanTrue()} if the boolean is true, otherwise {@link PlaceholderAPIPlugin#booleanFalse()}
|
||||
* @return {@link PlaceholderAPIPlugin#booleanTrue()} if the boolean is true,
|
||||
* otherwise {@link PlaceholderAPIPlugin#booleanFalse()}
|
||||
*/
|
||||
private @NotNull String bool(final boolean bool) {
|
||||
|
||||
return bool ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of online players from a world
|
||||
*
|
||||
* @param worldName the name of the world
|
||||
* @return {@code -1} if {@code worldName} is empty or the world doesn't exist, otherwise {@link World#getPlayers()}.size()
|
||||
* @return {@code -1} if {@code worldName} is empty or the world doesn't exist,
|
||||
* otherwise {@link World#getPlayers()}.size()
|
||||
*/
|
||||
private int getOnlinePlayers(@NotNull final String worldName) {
|
||||
|
||||
if (worldName.trim().isEmpty()) {
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
return Optional.ofNullable(Bukkit.getWorld(worldName))
|
||||
.map(World::getPlayers)
|
||||
.map(List::size)
|
||||
.orElse(-1);
|
||||
return Optional.ofNullable(Bukkit.getWorld(worldName)).map(World::getPlayers).map(List::size).orElse(-1);
|
||||
|
||||
}
|
||||
|
||||
// Per world counts
|
||||
private int getLocalChunks(String world){
|
||||
private int getLocalChunks(String world) {
|
||||
|
||||
return Bukkit.getWorld(world).getLoadedChunks().length;
|
||||
|
||||
}
|
||||
|
||||
private int getLocalPlayers(String world){
|
||||
private int getLocalPlayers(String world) {
|
||||
|
||||
return Bukkit.getWorld(world).getPlayers().size();
|
||||
|
||||
}
|
||||
|
||||
private int getLocalEntities(String world){
|
||||
private int getLocalEntities(String world) {
|
||||
|
||||
return Bukkit.getWorld(world).getEntities().size();
|
||||
|
||||
}
|
||||
|
||||
private int getLocalLivingEntities(String world){
|
||||
private int getLocalLivingEntities(String world) {
|
||||
|
||||
return Bukkit.getWorld(world).getLivingEntities().size();
|
||||
|
||||
}
|
||||
|
||||
// Paper method
|
||||
private int getLocalTileEntities(String world){
|
||||
private int getLocalTileEntities(String world) {
|
||||
|
||||
return Bukkit.getWorld(world).getTileEntityCount();
|
||||
|
||||
}
|
||||
|
||||
private int getLocalTickableTileEntities(String world){
|
||||
private int getLocalTickableTileEntities(String world) {
|
||||
|
||||
return Bukkit.getWorld(world).getTickableTileEntityCount();
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
@Override
|
||||
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||
|
||||
switch (params) {
|
||||
|
||||
// ----- Players placeholders
|
||||
case "online":
|
||||
return String.valueOf(Bukkit.getOnlinePlayers().size());
|
||||
@@ -229,84 +255,116 @@ public final class ServerExpansion extends PlaceholderExpansion implements Cache
|
||||
case "tps":
|
||||
return tpsFormatter.getTps(null);
|
||||
case "uptime":
|
||||
return timeFormatter.formatTimeInSeconds(TimeUnit.MILLISECONDS.toSeconds(ManagementFactory.getRuntimeMXBean().getUptime()));
|
||||
return timeFormatter.formatTimeInSeconds(
|
||||
TimeUnit.MILLISECONDS.toSeconds(ManagementFactory.getRuntimeMXBean().getUptime()));
|
||||
case "total_chunks":
|
||||
return getFromCache("chunks", () -> getFromAllWorlds(world -> world.getLoadedChunks().length));
|
||||
case "total_living_entities":
|
||||
return getFromCache("livingEntities", () -> getFromAllWorlds(world -> world.getLivingEntities().size()));
|
||||
return getFromCache("livingEntities",
|
||||
() -> getFromAllWorlds(world -> world.getLivingEntities().size()));
|
||||
case "total_entities":
|
||||
return getFromCache("totalEntities", () -> getFromAllWorlds(world -> world.getEntities().size()));
|
||||
case "has_whitelist":
|
||||
return bool(Bukkit.hasWhitelist());
|
||||
|
||||
}
|
||||
|
||||
// tps_<type>
|
||||
if (params.startsWith("tps_")) {
|
||||
|
||||
return tpsFormatter.getTps(params.substring("tps_".length()));
|
||||
|
||||
}
|
||||
|
||||
// online_<world name>
|
||||
if (params.startsWith("online_")) {
|
||||
|
||||
return String.valueOf(getOnlinePlayers(params.substring("online_".length())));
|
||||
|
||||
}
|
||||
|
||||
// time_<simple date format>
|
||||
if (params.startsWith("time_")) {
|
||||
|
||||
return timeFormatter.formatTime(params.substring("time_".length()));
|
||||
|
||||
}
|
||||
|
||||
// countdown_raw_<date> or countdown_raw_<custom format>_<date>
|
||||
if (params.startsWith("countdown_raw_")) {
|
||||
return timeFormatter.calculateTimeBetweenWithoutFormat(player, params.substring("countdown_raw_".length()), true);
|
||||
|
||||
return timeFormatter.calculateTimeBetweenWithoutFormat(player, params.substring("countdown_raw_".length()),
|
||||
true);
|
||||
|
||||
}
|
||||
|
||||
// countdown_<date> or countdown_<custom format>_<date>
|
||||
if (params.startsWith("countdown_")) {
|
||||
|
||||
return timeFormatter.calculateTimeBetween(player, params.substring("countdown_".length()), true, true);
|
||||
|
||||
}
|
||||
|
||||
// countup_raw_<date> or countup_raw_<custom format>_<date>
|
||||
if (params.startsWith("countup_raw_")) {
|
||||
return timeFormatter.calculateTimeBetweenWithoutFormat(player, params.substring("countup_raw_".length()), false);
|
||||
|
||||
return timeFormatter.calculateTimeBetweenWithoutFormat(player, params.substring("countup_raw_".length()),
|
||||
false);
|
||||
|
||||
}
|
||||
|
||||
// countup_<date> or countup_<custom format>_<date>
|
||||
if (params.startsWith("countup_")) {
|
||||
|
||||
return timeFormatter.calculateTimeBetween(player, params.substring("countup_".length()), false, true);
|
||||
|
||||
}
|
||||
|
||||
// Per world counts placeholders
|
||||
if (params.startsWith("total_chunks_")) {
|
||||
|
||||
params = params.replace("total_chunks_", "");
|
||||
return String.valueOf(getLocalChunks(params));
|
||||
|
||||
}
|
||||
|
||||
if (params.startsWith("total_players_")) {
|
||||
|
||||
params = params.replace("total_players_", "");
|
||||
return String.valueOf(getLocalPlayers(params));
|
||||
|
||||
}
|
||||
|
||||
if (params.startsWith("total_entities_")) {
|
||||
|
||||
params = params.replace("total_entities_", "");
|
||||
return String.valueOf(getLocalEntities(params));
|
||||
|
||||
}
|
||||
|
||||
if (params.startsWith("total_living_entities_")) {
|
||||
|
||||
params = params.replace("total_living_entities_", "");
|
||||
return String.valueOf(getLocalLivingEntities(params));
|
||||
|
||||
}
|
||||
|
||||
if (params.startsWith("total_tile_entities_")) {
|
||||
|
||||
params = params.replace("total_tile_entities_", "");
|
||||
return String.valueOf(getLocalTileEntities(params));
|
||||
|
||||
}
|
||||
|
||||
if (params.startsWith("total_tick_tile_entities_")) {
|
||||
|
||||
params = params.replace("total_tick_tile_entities_", "");
|
||||
return String.valueOf(getLocalTickableTileEntities(params));
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,18 +9,27 @@ import java.util.logging.Level;
|
||||
|
||||
public final class Logging {
|
||||
|
||||
private static void log(@NotNull final Level level, @Nullable final Throwable throwable, @NotNull final String message, @NotNull final Object... args) {
|
||||
PlaceholderAPIPlugin.getInstance()
|
||||
.getLogger()
|
||||
.log(level, "[server] " + MessageFormat.format(message, args), throwable);
|
||||
private static void log(@NotNull final Level level, @Nullable final Throwable throwable,
|
||||
@NotNull final String message, @NotNull final Object... args)
|
||||
{
|
||||
|
||||
PlaceholderAPIPlugin.getInstance().getLogger().log(level,
|
||||
"[Server-PAPI] " + MessageFormat.format(message, args), throwable);
|
||||
|
||||
}
|
||||
|
||||
public static void warn(@NotNull final String message, @NotNull final Object... args) {
|
||||
|
||||
log(Level.WARNING, null, message, args);
|
||||
|
||||
}
|
||||
|
||||
public static void error(@NotNull final Throwable throwable, @NotNull final String message, @NotNull final Object... args) {
|
||||
public static void error(@NotNull final Throwable throwable, @NotNull final String message,
|
||||
@NotNull final Object... args)
|
||||
{
|
||||
|
||||
log(Level.SEVERE, throwable, message, args);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package at.helpch.placeholderapi.expansion.server.util;
|
||||
|
||||
import io.papermc.paper.ServerBuildInfo;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -24,11 +23,13 @@ public final class ServerUtil {
|
||||
private static final String build;
|
||||
|
||||
static {
|
||||
|
||||
variants.put("io.papermc.paper.threadedregions.RegionizedServer", "Folia");
|
||||
variants.put("net.pl3x.purpur.PurpurConfig", "Purpur");
|
||||
variants.put("gg.airplane.AirplaneConfig", "Airplane");
|
||||
variants.put("com.tuinity.tuinity.config.TuinityConfig", "Tuinity");
|
||||
variants.put("io.papermc.paper.configuration.ConfigurationLoaders", "Paper"); // New config location for Paper 1.19+
|
||||
variants.put("io.papermc.paper.configuration.ConfigurationLoaders", "Paper"); // New config location for Paper
|
||||
// 1.19+
|
||||
variants.put("com.destroystokyo.paper.PaperConfig", "Paper"); // Still supported by Paper, but deprecated.
|
||||
variants.put("org.spigotmc.SpigotConfig", "Spigot");
|
||||
|
||||
@@ -36,156 +37,282 @@ public final class ServerUtil {
|
||||
tpsField = getTpsHandler();
|
||||
variant = findVariant();
|
||||
build = findBuild();
|
||||
|
||||
}
|
||||
|
||||
private static String findVariant() {
|
||||
if (hasServerBuildInfo())
|
||||
return getVariant0();
|
||||
|
||||
final Optional<String> buildInfoVariant = getVariant0();
|
||||
if (buildInfoVariant.isPresent())
|
||||
return buildInfoVariant.get();
|
||||
|
||||
for (final Map.Entry<String, String> entry : variants.entrySet()) {
|
||||
|
||||
try {
|
||||
Class.forName(entry.getKey());
|
||||
return entry.getValue();
|
||||
} catch (ClassNotFoundException ignored) { }
|
||||
|
||||
Class.forName(entry.getKey());
|
||||
return entry.getValue();
|
||||
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Source: https://github.com/PaperMC/Paper/blob/f7717c3/patches/server/0027-Show-Paper-in-client-crashes-server-lists-and-Mojang.patch#L17
|
||||
// Source:
|
||||
// https://github.com/PaperMC/Paper/blob/f7717c3/patches/server/0027-Show-Paper-in-client-crashes-server-lists-and-Mojang.patch#L17
|
||||
if (craftServer != null) {
|
||||
|
||||
try {
|
||||
return (String) craftServer.getClass()
|
||||
.getMethod("getServerModName")
|
||||
.invoke(craftServer);
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) { }
|
||||
|
||||
return (String) craftServer.getClass().getMethod("getServerModName").invoke(craftServer);
|
||||
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
return "Spigot";
|
||||
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
|
||||
return "Unknown"; // Not even spigot??
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Object getCraftServer() {
|
||||
|
||||
try {
|
||||
Class<?> clas;
|
||||
|
||||
final Class<?> clas;
|
||||
|
||||
if (VersionHelper.IS_1_17_OR_HIGHER) {
|
||||
|
||||
clas = Class.forName("net.minecraft.server.MinecraftServer");
|
||||
|
||||
} else {
|
||||
clas = Class.forName(String.format("net.minecraft.server.%s.MinecraftServer", VersionHelper.getNmsVersion()));
|
||||
|
||||
clas = Class.forName(
|
||||
String.format("net.minecraft.server.%s.MinecraftServer", VersionHelper.getNmsVersion()));
|
||||
|
||||
}
|
||||
|
||||
return clas.getMethod("getServer").invoke(null);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
Logging.error(e, "Could not find class MinecraftServer");
|
||||
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
|
||||
Logging.error(e, "Could not invoke method MinecraftServer#getServer");
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private static Field getTpsHandler() {
|
||||
|
||||
try {
|
||||
|
||||
Bukkit.class.getMethod("getTPS");
|
||||
hasTpsMethod = true;
|
||||
return null;
|
||||
} catch (NoSuchMethodException ignored) { }
|
||||
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
|
||||
}
|
||||
|
||||
if (craftServer == null) {
|
||||
Logging.warn("Could not get field 'recentTps' from class MinecraftServer because variable 'craftServer' is null");
|
||||
|
||||
Logging.warn(
|
||||
"Could not get field 'recentTps' from class MinecraftServer because variable 'craftServer' is null");
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
return craftServer.getClass().getField("recentTps");
|
||||
|
||||
} catch (NoSuchFieldException e) {
|
||||
|
||||
Logging.error(e, "Could not find field 'recentTps' in class {0}", craftServer.getClass().getName());
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static String findBuild() {
|
||||
if (hasServerBuildInfo())
|
||||
return getBuild0();
|
||||
|
||||
String[] buildParts = Bukkit.getVersion().split("-");
|
||||
final Optional<String> buildInfoBuild = getBuild0();
|
||||
if (buildInfoBuild.isPresent())
|
||||
return buildInfoBuild.get();
|
||||
|
||||
final String[] buildParts = Bukkit.getVersion().split("-");
|
||||
|
||||
switch (getVariant().toLowerCase()) {
|
||||
|
||||
case "spigot":
|
||||
return buildParts[0];
|
||||
|
||||
// Source: https://github.com/PaperMC/Paper/blob/0ae58c0/patches/server/0001-Setup-Gradle-project.patch#L75
|
||||
// Source:
|
||||
// https://github.com/PaperMC/Paper/blob/0ae58c0/patches/server/0001-Setup-Gradle-project.patch#L75
|
||||
case "paper":
|
||||
// Source: https://github.com/Tuinity/Tuinity/blob/4c31ea1/patches/server/0001-Build-changes.patch#L34
|
||||
// Source:
|
||||
// https://github.com/Tuinity/Tuinity/blob/4c31ea1/patches/server/0001-Build-changes.patch#L34
|
||||
case "tuinity":
|
||||
// Source: https://github.com/PurpurMC/Purpur/blob/c049bfb/patches/server/0002-Rebrand.patch#L44
|
||||
// Source:
|
||||
// https://github.com/PurpurMC/Purpur/blob/c049bfb/patches/server/0002-Rebrand.patch#L44
|
||||
case "purpur":
|
||||
// Source: https://github.com/TECHNOVE/Airplane/blob/af3563c/patches/server/0002-Airplane-Branding-Changes.patch#L41
|
||||
// Source:
|
||||
// https://github.com/TECHNOVE/Airplane/blob/af3563c/patches/server/0002-Airplane-Branding-Changes.patch#L41
|
||||
case "airplane": {
|
||||
|
||||
// Format: git-<Paper/Tuinity/Purpur/Airplane>-<version>
|
||||
if (buildParts.length >= 3) {
|
||||
|
||||
if (buildParts[2].contains(" ")) {
|
||||
|
||||
return buildParts[2].substring(0, buildParts[2].indexOf(" "));
|
||||
|
||||
} else {
|
||||
|
||||
return buildParts[2];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
|
||||
}
|
||||
|
||||
public static String getVariant() {
|
||||
|
||||
return variant;
|
||||
|
||||
}
|
||||
|
||||
public static String getServerVersion() {
|
||||
|
||||
return VersionHelper.MINECRAFT_VERSION;
|
||||
|
||||
}
|
||||
|
||||
public static String getBuild() {
|
||||
|
||||
return build;
|
||||
|
||||
}
|
||||
|
||||
public static double[] getTps() {
|
||||
|
||||
if (hasTpsMethod) {
|
||||
|
||||
return Bukkit.getTPS();
|
||||
|
||||
}
|
||||
|
||||
if (craftServer == null || tpsField == null) {
|
||||
return new double[]{0, 0, 0};
|
||||
|
||||
return new double[] { 0, 0, 0 };
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
return (double[]) tpsField.get(craftServer);
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
return new double[]{0, 0, 0};
|
||||
|
||||
return new double[] { 0, 0, 0 };
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Available since recent 1.20.6 versions of Paper. Allows easier retrieval of certain info.
|
||||
private static boolean hasServerBuildInfo() {
|
||||
private static Optional<Object> getServerBuildInfo() {
|
||||
|
||||
try {
|
||||
Class.forName("io.papermc.paper.ServerBuildInfo");
|
||||
return true;
|
||||
} catch(ClassNotFoundException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getVariant0() {
|
||||
return ServerBuildInfo.buildInfo().brandName();
|
||||
}
|
||||
final Class<?> buildInfoClass = Class.forName("io.papermc.paper.ServerBuildInfo");
|
||||
return Optional.of(buildInfoClass.getMethod("buildInfo").invoke(null));
|
||||
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
|
||||
return Optional.empty();
|
||||
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ignored) {
|
||||
|
||||
return Optional.empty();
|
||||
|
||||
private static String getBuild0() {
|
||||
OptionalInt buildNumber = ServerBuildInfo.buildInfo().buildNumber();
|
||||
if (!buildNumber.isPresent()) {
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
return String.valueOf(buildNumber.getAsInt());
|
||||
}
|
||||
|
||||
// Available since recent 1.20.6 versions of Paper. Reflection keeps the project
|
||||
// buildable against 1.19.4.
|
||||
private static Optional<String> getVariant0() {
|
||||
|
||||
final Optional<Object> buildInfo = getServerBuildInfo();
|
||||
if (!buildInfo.isPresent())
|
||||
return Optional.empty();
|
||||
|
||||
try {
|
||||
|
||||
return Optional.of((String) buildInfo.get().getClass().getMethod("brandName").invoke(buildInfo.get()));
|
||||
|
||||
} catch (ClassCastException | IllegalAccessException | InvocationTargetException
|
||||
| NoSuchMethodException ignored)
|
||||
{
|
||||
|
||||
return Optional.empty();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Optional<String> getBuild0() {
|
||||
|
||||
final Optional<Object> buildInfo = getServerBuildInfo();
|
||||
if (!buildInfo.isPresent())
|
||||
return Optional.empty();
|
||||
|
||||
try {
|
||||
|
||||
final Object buildNumber = buildInfo.get().getClass().getMethod("buildNumber").invoke(buildInfo.get());
|
||||
if (!(buildNumber instanceof OptionalInt))
|
||||
return Optional.empty();
|
||||
|
||||
final OptionalInt optionalBuildNumber = (OptionalInt) buildNumber;
|
||||
if (!optionalBuildNumber.isPresent()) {
|
||||
|
||||
return Optional.of("Unknown");
|
||||
|
||||
}
|
||||
|
||||
return Optional.of(String.valueOf(optionalBuildNumber.getAsInt()));
|
||||
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ignored) {
|
||||
|
||||
return Optional.empty();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,53 +27,75 @@ public final class TimeFormatter {
|
||||
private final ZoneId timeZone;
|
||||
private final Map<@NotNull String, @Nullable Object> timeUnitSuffixes;
|
||||
|
||||
public TimeFormatter(
|
||||
@NotNull final Locale timeLocale, @NotNull final ZoneId timeZone,
|
||||
@NotNull Map<@NotNull String, @Nullable Object> timeUnitSuffixes
|
||||
) {
|
||||
public TimeFormatter(@NotNull final Locale timeLocale, @NotNull final ZoneId timeZone,
|
||||
@NotNull Map<@NotNull String, @Nullable Object> timeUnitSuffixes)
|
||||
{
|
||||
|
||||
this.timeLocale = timeLocale;
|
||||
this.timeZone = timeZone;
|
||||
this.timeUnitSuffixes = timeUnitSuffixes;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string to a {@link DateTimeFormatter} and cache it
|
||||
*
|
||||
* @param pattern pattern to parse
|
||||
* @return {@link DateTimeFormatter} if the argument is a valid pattern, otherwise null
|
||||
* @return {@link DateTimeFormatter} if the argument is a valid pattern,
|
||||
* otherwise null
|
||||
*/
|
||||
public @Nullable DateTimeFormatter parseFormat(@NotNull final String pattern) {
|
||||
|
||||
return dateFormatsCache.computeIfAbsent(pattern, __ -> {
|
||||
|
||||
try {
|
||||
|
||||
return DateTimeFormatter.ofPattern(pattern, timeLocale);
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
||||
Logging.error(e, "Could not parse DateTimeFormatter from pattern \"{0}\"", pattern);
|
||||
|
||||
} catch (DateTimeException e) {
|
||||
|
||||
if (e.getMessage().contains("obtain LocalTime from TemporalAccessor")) {
|
||||
Logging.error(e, "The pattern \"{0}\" might be missing the time definition, try to add 'HH' at the end and set it to '00' (beginning of the day)", pattern);
|
||||
|
||||
Logging.error(e,
|
||||
"The pattern \"{0}\" might be missing the time definition, try to add 'HH' at the end and set it to '00' (beginning of the day)",
|
||||
pattern);
|
||||
|
||||
} else {
|
||||
|
||||
Logging.error(e, "Could not parse DateTimeFormatter from pattern \"{0}\"", pattern);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the current time with the given format
|
||||
*
|
||||
* @param format format
|
||||
* @return {@code null} if the format is empty or invalid, otherwise {@link ZonedDateTime#now(ZoneId)} formatted
|
||||
* @return {@code null} if the format is empty or invalid, otherwise
|
||||
* {@link ZonedDateTime#now(ZoneId)} formatted
|
||||
*/
|
||||
public @Nullable String formatTime(@NotNull final String format) {
|
||||
|
||||
if (format.trim().isEmpty()) {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
return Optional.ofNullable(parseFormat(format))
|
||||
.map(formatter -> ZonedDateTime.now(timeZone).format(formatter))
|
||||
.orElse(null);
|
||||
return Optional.ofNullable(parseFormat(format)).map(formatter -> ZonedDateTime.now(timeZone).format(formatter))
|
||||
.orElse(null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,11 +105,16 @@ public final class TimeFormatter {
|
||||
* @return time formatted
|
||||
*/
|
||||
public @NotNull String formatTimeInSeconds(long time) {
|
||||
|
||||
final StringJoiner joiner = new StringJoiner(" ");
|
||||
final BiConsumer<@NotNull Long, @Nullable Object> appendTime = (value, unit) -> {
|
||||
|
||||
if (value > 0 && unit != null) {
|
||||
|
||||
joiner.add(value + unit.toString());
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
long seconds = time;
|
||||
@@ -107,73 +134,98 @@ public final class TimeFormatter {
|
||||
appendTime.accept(minutes, timeUnitSuffixes.get("minute"));
|
||||
appendTime.accept(seconds, timeUnitSuffixes.get("second"));
|
||||
return joiner.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the time between {@link ZonedDateTime#now(ZoneId)} and another date and return a formatted value
|
||||
* using {@link #formatTimeInSeconds(long)} if {@code formatTime} is {@code true}.
|
||||
* Calculate the time between {@link ZonedDateTime#now(ZoneId)} and another date
|
||||
* and return a formatted value using {@link #formatTimeInSeconds(long)} if
|
||||
* {@code formatTime} is {@code true}.
|
||||
*
|
||||
* @param player player
|
||||
* @param args arguments received on {@link me.clip.placeholderapi.expansion.PlaceholderExpansion#onRequest(OfflinePlayer, String)}
|
||||
* @param isCountdown whether the time calculated is for a countdown or a count-up
|
||||
* @param formatTime whether the time should be formatted with {@link #formatTimeInSeconds(long)}
|
||||
* @param args arguments received on
|
||||
* {@link me.clip.placeholderapi.expansion.PlaceholderExpansion#onRequest(OfflinePlayer, String)}
|
||||
* @param isCountdown whether the time calculated is for a countdown or a
|
||||
* count-up
|
||||
* @param formatTime whether the time should be formatted with
|
||||
* {@link #formatTimeInSeconds(long)}
|
||||
* @return time formatter
|
||||
*/
|
||||
public @NotNull String calculateTimeBetween(
|
||||
@Nullable final OfflinePlayer player, @NotNull final String args,
|
||||
final boolean isCountdown, final boolean formatTime
|
||||
) {
|
||||
DateTimeFormatter formatter;
|
||||
String otherDateString;
|
||||
public @NotNull String calculateTimeBetween(@Nullable final OfflinePlayer player, @NotNull final String args,
|
||||
final boolean isCountdown, final boolean formatTime)
|
||||
{
|
||||
|
||||
final DateTimeFormatter formatter;
|
||||
final String otherDateString;
|
||||
|
||||
// Placeholder with custom time format
|
||||
if (args.contains("_")) {
|
||||
|
||||
final String[] parts = PlaceholderAPI.setBracketPlaceholders(player, args).split("_");
|
||||
|
||||
if (parts.length != 2) {
|
||||
|
||||
return "invalid format and time";
|
||||
|
||||
}
|
||||
|
||||
formatter = this.parseFormat(parts[0]);
|
||||
otherDateString = parts[1];
|
||||
|
||||
} else {
|
||||
|
||||
formatter = this.parseFormat(PlaceholderAPIPlugin.getInstance().getPlaceholderAPIConfig().dateFormat());
|
||||
otherDateString = args;
|
||||
|
||||
}
|
||||
|
||||
if (formatter == null) {
|
||||
|
||||
return "invalid date format";
|
||||
|
||||
}
|
||||
|
||||
DateTimeFormatter zonedFormatter = formatter.withZone(timeZone);
|
||||
final DateTimeFormatter zonedFormatter = formatter.withZone(timeZone);
|
||||
|
||||
try {
|
||||
ZonedDateTime now = ZonedDateTime.now(timeZone);
|
||||
ZonedDateTime otherDate = ZonedDateTime.parse(otherDateString, zonedFormatter);
|
||||
|
||||
final ZonedDateTime now = ZonedDateTime.now(timeZone);
|
||||
final ZonedDateTime otherDate = ZonedDateTime.parse(otherDateString, zonedFormatter);
|
||||
|
||||
if (otherDate.isEqual(now)) {
|
||||
|
||||
return "0";
|
||||
|
||||
}
|
||||
|
||||
// 'otherDate' should be after 'now' for countdowns and before for count-ups
|
||||
if ((isCountdown && otherDate.isBefore(now)) || (!isCountdown && otherDate.isAfter(now))) {
|
||||
|
||||
return "0";
|
||||
|
||||
}
|
||||
|
||||
final long time = isCountdown ? now.until(otherDate, ChronoUnit.SECONDS) : otherDate.until(now, ChronoUnit.SECONDS);
|
||||
final long time = isCountdown ? now.until(otherDate, ChronoUnit.SECONDS)
|
||||
: otherDate.until(now, ChronoUnit.SECONDS);
|
||||
return formatTime ? this.formatTimeInSeconds(time) : String.valueOf(time);
|
||||
|
||||
} catch (DateTimeParseException e) {
|
||||
|
||||
final String type = isCountdown ? "countdown" : "count-up";
|
||||
Logging.error(e, "Could not calculate {0} (format: \"{1}\", other date: \"{2}\")", type, zonedFormatter.toString(), otherDateString);
|
||||
Logging.error(e, "Could not calculate {0} (format: \"{1}\", other date: \"{2}\")", type,
|
||||
zonedFormatter.toString(), otherDateString);
|
||||
return "invalid date";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public @NotNull String calculateTimeBetweenWithoutFormat(
|
||||
@Nullable final OfflinePlayer player, @NotNull final String args,
|
||||
final boolean isCountdown
|
||||
) {
|
||||
public @NotNull String calculateTimeBetweenWithoutFormat(@Nullable final OfflinePlayer player,
|
||||
@NotNull final String args, final boolean isCountdown)
|
||||
{
|
||||
|
||||
return calculateTimeBetween(player, args, isCountdown, false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,10 +18,14 @@ public class TpsFormatter {
|
||||
* @param mediumColor color for {@code tps < 18.0}
|
||||
* @param highColor color for {@code tps > 18.0}
|
||||
*/
|
||||
public TpsFormatter(@NotNull final String lowColor, @NotNull final String mediumColor, @NotNull final String highColor) {
|
||||
public TpsFormatter(@NotNull final String lowColor, @NotNull final String mediumColor,
|
||||
@NotNull final String highColor)
|
||||
{
|
||||
|
||||
this.lowColor = ChatColor.translateAlternateColorCodes('&', lowColor);
|
||||
this.mediumColor = ChatColor.translateAlternateColorCodes('&', mediumColor);
|
||||
this.highColor = ChatColor.translateAlternateColorCodes('&', highColor);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,8 +35,10 @@ public class TpsFormatter {
|
||||
* @return tps rounded
|
||||
*/
|
||||
private @NotNull String round(final double tps) {
|
||||
|
||||
final String finalTps = String.format("%.2f", tps);
|
||||
return (tps > 20.0 ? "*" : "") + finalTps;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,40 +48,57 @@ public class TpsFormatter {
|
||||
* @return color for the tps
|
||||
*/
|
||||
private @NotNull String getColor(final double tps) {
|
||||
|
||||
return (tps > 18.0) ? highColor : (tps > 16.0) ? mediumColor : lowColor;
|
||||
|
||||
}
|
||||
|
||||
private @NotNull String getPercent(final double tps) {
|
||||
|
||||
final double percent = Math.min(Math.round(100 / 20.0 * tps), 100.0);
|
||||
return (tps > 20.0 ? "*" : "") + percent + '%';
|
||||
|
||||
}
|
||||
|
||||
private @NotNull String getColoredTps(final double tps) {
|
||||
|
||||
return getColor(tps) + round(tps);
|
||||
|
||||
}
|
||||
|
||||
private @NotNull String getColoredTpsPercent(final double tps) {
|
||||
|
||||
return getColor(tps) + getPercent(tps);
|
||||
|
||||
}
|
||||
|
||||
private @NotNull String getAllTps(@NotNull final Function<Double, String> formatter) {
|
||||
|
||||
final StringJoiner joiner = new StringJoiner(ChatColor.GRAY + ", ");
|
||||
|
||||
for (final double tps : ServerUtil.getTps()) {
|
||||
|
||||
joiner.add(formatter.apply(tps));
|
||||
|
||||
}
|
||||
|
||||
return joiner.toString();
|
||||
|
||||
}
|
||||
|
||||
public @Nullable String getTps(@Nullable final String type) {
|
||||
if (ServerUtil.getVariant().equals("Folia")) return null;
|
||||
|
||||
if (ServerUtil.getVariant().equals("Folia"))
|
||||
return null;
|
||||
|
||||
if (type == null || type.isEmpty()) {
|
||||
|
||||
return getAllTps(this::getColoredTps);
|
||||
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
|
||||
case "1":
|
||||
case "one":
|
||||
return round(ServerUtil.getTps()[0]);
|
||||
@@ -126,9 +149,11 @@ public class TpsFormatter {
|
||||
case "15_percent_colored":
|
||||
case "fifteen_percent_colored":
|
||||
return getColoredTpsPercent(ServerUtil.getTps()[2]);
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,8 +27,6 @@ import com.google.common.primitives.Ints;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -48,72 +46,101 @@ public final class VersionHelper {
|
||||
public static final boolean IS_1_17_OR_HIGHER = CURRENT_VERSION >= V1_17;
|
||||
|
||||
/**
|
||||
* Check if the server has access to the Paper API
|
||||
* Taken from <a href="https://github.com/PaperMC/PaperLib">PaperLib</a>
|
||||
* Check if the server has access to the Paper API Taken from
|
||||
* <a href="https://github.com/PaperMC/PaperLib">PaperLib</a>
|
||||
*
|
||||
* @return True if on Paper server (or forks), false anything else
|
||||
*/
|
||||
private static boolean checkPaper() {
|
||||
final String[] configClasses = {"io.papermc.paper.configuration.ConfigurationLoaders", "com.destroystokyo.paper.PaperConfig"};
|
||||
|
||||
final String[] configClasses = { "io.papermc.paper.configuration.ConfigurationLoaders",
|
||||
"com.destroystokyo.paper.PaperConfig" };
|
||||
|
||||
for (String configClass : configClasses) {
|
||||
|
||||
try {
|
||||
|
||||
Class.forName(configClass);
|
||||
return true;
|
||||
} catch (ClassNotFoundException ignored) { }
|
||||
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current server version
|
||||
*
|
||||
* @return A protocol like number representing the version, for example 1.16.5 - 1165
|
||||
* @return A protocol like number representing the version, for example 1.16.5 -
|
||||
* 1165
|
||||
*/
|
||||
private static int getCurrentVersion() {
|
||||
|
||||
// No need to cache since will only run once
|
||||
final Matcher matcher = Pattern.compile("(?<version>\\d+\\.\\d+)(?<patch>\\.\\d+)?").matcher(MINECRAFT_VERSION);
|
||||
|
||||
final StringBuilder stringBuilder = new StringBuilder();
|
||||
if (matcher.find()) {
|
||||
|
||||
stringBuilder.append(matcher.group("version").replace(".", ""));
|
||||
final String patch = matcher.group("patch");
|
||||
if (patch == null) stringBuilder.append("0");
|
||||
else stringBuilder.append(patch.replace(".", ""));
|
||||
if (patch == null)
|
||||
stringBuilder.append("0");
|
||||
else
|
||||
stringBuilder.append(patch.replace(".", ""));
|
||||
|
||||
}
|
||||
|
||||
//noinspection UnstableApiUsage
|
||||
// noinspection UnstableApiUsage
|
||||
final Integer version = Ints.tryParse(stringBuilder.toString());
|
||||
|
||||
// Should never fail
|
||||
if (version == null) throw new IllegalArgumentException("Could not retrieve server version!");
|
||||
if (version == null)
|
||||
throw new IllegalArgumentException("Could not retrieve server version!");
|
||||
|
||||
return version;
|
||||
|
||||
}
|
||||
|
||||
private static String getMinecraftVersion() {
|
||||
|
||||
if (IS_PAPER) {
|
||||
|
||||
try {
|
||||
|
||||
// Paper method from 2020 - returns the version like 1.20.1
|
||||
return Bukkit.getMinecraftVersion();
|
||||
|
||||
} catch (NoSuchMethodError ignored) {
|
||||
|
||||
// The version is formatted as 1.20.1-R0.1-SNAPSHOT
|
||||
return Bukkit.getBukkitVersion().split("-")[0];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// The version is formatted as 1.20.1-R0.1-SNAPSHOT
|
||||
return Bukkit.getBukkitVersion().split("-")[0];
|
||||
|
||||
}
|
||||
|
||||
public static String getNmsVersion() {
|
||||
|
||||
final String version = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return version.substring(version.lastIndexOf('.') + 1);
|
||||
|
||||
}
|
||||
|
||||
public static Class<?> craftClass(@NotNull final String name) throws ClassNotFoundException {
|
||||
|
||||
return Class.forName(CRAFTBUKKIT_PACKAGE + "." + name);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user