New formatting and stricter java rules
This commit is contained in:
1 parent
2b2df24420
commit
f2aa64a5ed
25 files changed
+1775
-386
No files matched your search
+2
-1
@@ -34,6 +34,7 @@ build/
|
||||
.settings/
|
||||
.project
|
||||
.classpath
|
||||
.checkstyle
|
||||
bin/
|
||||
|
||||
# User-specific stuff
|
||||
@@ -44,4 +45,4 @@ bin/
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
out/
|
||||
+33
-26
@@ -2,11 +2,12 @@
|
||||
|
||||
/* ------------------------------ Plugins ------------------------------ */
|
||||
plugins {
|
||||
id("java") // Tell gradle this is a java project.
|
||||
id("java-library") // Import helper for source-based libraries.
|
||||
id("com.diffplug.spotless") version "7.0.4" // Import auto-formatter.
|
||||
id("com.gradleup.shadow") version "8.3.6" // Import shadow API.
|
||||
eclipse // Import eclipse plugin for IDE integration.
|
||||
id("java") // Import Java plugin.
|
||||
id("java-library") // Import Java Library plugin.
|
||||
id("com.diffplug.spotless") version "7.0.4" // Import Spotless plugin.
|
||||
id("com.gradleup.shadow") version "8.3.6" // Import Shadow plugin.
|
||||
id("checkstyle") // Import Checkstyle plugin.
|
||||
eclipse // Import Eclipse plugin.
|
||||
}
|
||||
|
||||
/* ------------------------------- JDK --------------------------------- */
|
||||
@@ -38,12 +39,9 @@ repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven { url = uri("https://repo.purpurmc.org/snapshots") }
|
||||
maven {
|
||||
url = uri("https://repo.codemc.io/repository/maven-public/") // Import the CodeMC Maven Repository.
|
||||
}
|
||||
maven {
|
||||
url = uri("https://maven.enginehub.org/repo/") // Import the EngineHub Maven Repository.
|
||||
}
|
||||
maven { url = uri("https://repo.papermc.io/repository/maven-public/") } // Import the PaperMC Maven Repository.
|
||||
maven { url = uri("https://repo.codemc.io/repository/maven-public/") } // Import the CodeMC Maven Repository.
|
||||
maven { url = uri("https://maven.enginehub.org/repo/") } // Import the EngineHub Maven Repository.
|
||||
}
|
||||
|
||||
/* ---------------------- Java project deps ---------------------------- */
|
||||
@@ -54,6 +52,7 @@ dependencies {
|
||||
compileOnly("io.github.miniplaceholders:miniplaceholders-api:2.2.3") // Import MiniPlaceholders API.
|
||||
compileOnly("net.luckperms:api:5.4") // Import LuckPerms API.
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.13.3") // Import JUnit 5 API.
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.19:2.29.0") // Import MockBukkit 1.19.
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher") // Import JUnit's engine.
|
||||
}
|
||||
|
||||
@@ -72,36 +71,44 @@ tasks.shadowJar {
|
||||
|
||||
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
|
||||
|
||||
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) }
|
||||
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) } // Build depends on spotless and shadow.
|
||||
|
||||
/* --------------------------- Javac opts ------------------------------- */
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add("-Xlint:deprecation") // Triggers deprecation warning messages.
|
||||
options.encoding = "UTF-8"
|
||||
options.compilerArgs.add("-Xlint:deprecation") // Trigger deprecation warning messages.
|
||||
options.encoding = "UTF-8" // Use UTF-8 file encoding.
|
||||
options.isFork = true
|
||||
}
|
||||
|
||||
/* --------------------------------- Testing ---------------------------- */
|
||||
tasks.withType<Test>().configureEach { // Enable testing with JUnit 5.
|
||||
useJUnitPlatform()
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform() // Enable testing with JUnit 5.
|
||||
}
|
||||
|
||||
/* ----------------------------- Auto Formatting ------------------------ */
|
||||
spotless {
|
||||
java {
|
||||
removeUnusedImports()
|
||||
palantirJavaFormat()
|
||||
eclipse().configFile("config/formatter/eclipse-java-formatter.xml") // Eclipse java formatting.
|
||||
leadingTabsToSpaces() // Convert leftover leading tabs to spaces.
|
||||
removeUnusedImports() // Remove imports that aren't being called.
|
||||
}
|
||||
kotlinGradle {
|
||||
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) }
|
||||
target("build.gradle.kts", "settings.gradle.kts")
|
||||
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } // JetBrains Kotlin formatting.
|
||||
target("build.gradle.kts", "settings.gradle.kts") // Gradle files to format.
|
||||
}
|
||||
}
|
||||
|
||||
// This can't be put in eclipse.gradle.kts because Gradle is weird.
|
||||
subprojects {
|
||||
apply(plugin = "java-library")
|
||||
apply(plugin = "eclipse")
|
||||
eclipse.project.name = "${project.name}-${rootProject.name}"
|
||||
tasks.withType<Jar>().configureEach { archiveBaseName.set("${project.name}-${rootProject.name}") }
|
||||
checkstyle {
|
||||
toolVersion = "10.18.1" // Declare checkstyle version to use.
|
||||
configFile = file("config/checkstyle/checkstyle.xml") // Point checkstyle to config file.
|
||||
isIgnoreFailures = true // Don't fail the build if checkstyle does not pass.
|
||||
isShowViolations = true // Show the violations in any IDE with the checkstyle plugin.
|
||||
}
|
||||
|
||||
tasks.named("compileJava") {
|
||||
dependsOn("spotlessApply") // Run spotless before compiling with the JDK.
|
||||
}
|
||||
|
||||
tasks.named("spotlessCheck") {
|
||||
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
|
||||
}
|
||||
@@ -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,410 @@
|
||||
package net.trueog.utilitiesog;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
|
||||
public class FastOfflinePlayer implements OfflinePlayer {
|
||||
|
||||
UUID uuid;
|
||||
|
||||
public FastOfflinePlayer(UUID inputtedUUID) {
|
||||
|
||||
uuid = inputtedUUID;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Map<String, Object> serialize() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
UtilitiesOG.config().set("players." + getUniqueId(), this);
|
||||
UtilitiesOG.getPlugin().saveConfig();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getName() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull UUID getUniqueId() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PlayerProfile getPlayerProfile() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelisted(boolean value) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Player getPlayer() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFirstPlayed() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated The getLastPlayed API contract is ambiguous and the
|
||||
* implementation may or may not return the correct value. Use
|
||||
* {@link #getLastSeen()} instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getLastPlayed() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return getLastSeen();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPlayedBefore() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Location getBedSpawnLocation() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastLogin() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastSeen() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(@NotNull Statistic statistic, int amount) throws IllegalArgumentException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decrementStatistic(@NotNull Statistic statistic, int amount) throws IllegalArgumentException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatistic(@NotNull Statistic statistic, int newValue) throws IllegalArgumentException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatistic(@NotNull Statistic statistic) throws IllegalArgumentException {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatistic(@NotNull Statistic statistic, @NotNull Material material, int newValue)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int newValue) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Location getLastDeathLocation() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAllowFlight() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllowFlight(boolean flight) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlying() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlying(boolean value) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlySpeed(float value) throws IllegalArgumentException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWalkSpeed(float value) throws IllegalArgumentException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFlySpeed() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWalkSpeed() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Location getLocation() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleportOffline(@NotNull Location destination) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleportOffline(@NotNull Location destination, @NotNull TeleportCause cause) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<Boolean> teleportOfflineAsync(@NotNull Location destination) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<Boolean> teleportOfflineAsync(@NotNull Location destination,
|
||||
@NotNull TeleportCause cause)
|
||||
{
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +1,42 @@
|
||||
package net.trueog.utilitiesog;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
|
||||
public class InternalFunctions {
|
||||
|
||||
public static FileConfiguration getConfig() {
|
||||
|
||||
return UtilitiesOG.config();
|
||||
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
|
||||
return UtilitiesOG.prefix();
|
||||
|
||||
}
|
||||
|
||||
public static StateFlag getFlippyFlag() {
|
||||
|
||||
return UtilitiesOG.flippyFlag();
|
||||
|
||||
}
|
||||
|
||||
public static File getPhantomDisabledPlayersFile() {
|
||||
|
||||
return UtilitiesOG.phantomDisabledPlayersFile();
|
||||
|
||||
}
|
||||
|
||||
public static YamlConfiguration getPhantomPreferences() {
|
||||
|
||||
return UtilitiesOG.phantomPreferences();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -10,6 +9,16 @@ import java.util.UUID;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
@@ -34,12 +43,6 @@ import net.trueog.utilitiesog.modules.ChainArmorModule;
|
||||
import net.trueog.utilitiesog.modules.MockBambooModule;
|
||||
import net.trueog.utilitiesog.utils.PlaceholderUtils;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
// Declare main plugin class.
|
||||
public final class UtilitiesOG extends JavaPlugin {
|
||||
@@ -60,6 +63,7 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
if (!this.file.exists()) {
|
||||
|
||||
this.saveDefaultConfig();
|
||||
|
||||
}
|
||||
|
||||
config = this.getConfig();
|
||||
@@ -70,11 +74,13 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
if (!phantomPreferencesFile.exists()) {
|
||||
|
||||
phantomPreferencesFile.createNewFile();
|
||||
|
||||
}
|
||||
|
||||
} catch (IOException error) {
|
||||
|
||||
this.getLogger().severe("ERROR: Failed to create the phantom toggle cache file! " + error.getMessage());
|
||||
|
||||
}
|
||||
|
||||
phantomPreferences = YamlConfiguration.loadConfiguration(phantomPreferencesFile);
|
||||
@@ -82,11 +88,13 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
if (this.getConfig().getBoolean("ChainArmor")) {
|
||||
|
||||
ChainArmorModule.Enable();
|
||||
|
||||
}
|
||||
|
||||
if (this.getConfig().getBoolean("ColorCodes")) {
|
||||
|
||||
this.getCommand("colorcodes").setExecutor(new ColorCodesCommand());
|
||||
|
||||
}
|
||||
|
||||
if (this.getConfig().getBoolean("DisableEntityCramming")) {
|
||||
@@ -94,6 +102,7 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new DisableEntityCrammingListener(), this);
|
||||
|
||||
this.getCommand("togglecramming").setExecutor(new ToggleCrammingCommand());
|
||||
|
||||
}
|
||||
|
||||
if (this.getConfig().getBoolean("MiniPlaceholders")) {
|
||||
@@ -103,28 +112,27 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
|
||||
// Registering an Audience MiniPlaceholder.
|
||||
registerAudiencePlaceholder("player_display_name", (Player player) -> {
|
||||
LuckPerms luckPerms = LuckPermsProvider.get();
|
||||
User user = luckPerms.getUserManager().getUser(player.getUniqueId());
|
||||
|
||||
final LuckPerms luckPerms = LuckPermsProvider.get();
|
||||
final User user = luckPerms.getUserManager().getUser(player.getUniqueId());
|
||||
if (user == null) {
|
||||
|
||||
getPlugin()
|
||||
.getLogger()
|
||||
.info("ERROR: MiniPlaceholder processing error. Player: " + player.getName()
|
||||
+ " has no User object in LuckPerms!");
|
||||
getPlugin().getLogger().info("ERROR: MiniPlaceholder processing error. Player: " + player.getName()
|
||||
+ " has no User object in LuckPerms!");
|
||||
|
||||
return player.getName();
|
||||
|
||||
}
|
||||
|
||||
String primaryGroup = user.getPrimaryGroup();
|
||||
Group group = luckPerms.getGroupManager().getGroup(primaryGroup);
|
||||
final String primaryGroup = user.getPrimaryGroup();
|
||||
final Group group = luckPerms.getGroupManager().getGroup(primaryGroup);
|
||||
if (group == null) {
|
||||
|
||||
getPlugin()
|
||||
.getLogger()
|
||||
.info("ERROR: MiniPlaceholder processing error. User: " + player.getName()
|
||||
+ " has no Group assignment in LuckPerms!");
|
||||
getPlugin().getLogger().info("ERROR: MiniPlaceholder processing error. User: " + player.getName()
|
||||
+ " has no Group assignment in LuckPerms!");
|
||||
|
||||
return player.getName();
|
||||
|
||||
}
|
||||
|
||||
String prefix = null;
|
||||
@@ -135,23 +143,29 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
prefix = ((PrefixNode) node).getMetaValue();
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (prefix == null) {
|
||||
|
||||
return player.getName();
|
||||
|
||||
}
|
||||
|
||||
String colorCode = prefix.replaceAll(".*\\](.*)", "$1");
|
||||
final String colorCode = prefix.replaceAll(".*\\](.*)", "$1");
|
||||
|
||||
return "<luckperms_prefix>" + colorCode + " " + player.getName();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (this.getConfig().getBoolean("MockBamboo")) {
|
||||
|
||||
MockBambooModule.Enable();
|
||||
|
||||
}
|
||||
|
||||
if (this.getConfig().getBoolean("NoFlippy")) {
|
||||
@@ -163,18 +177,22 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
} else {
|
||||
|
||||
this.getLogger().severe("WorldGuard is not installed! Disabling NoFlippy...");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.getConfig().getBoolean("Ping")) {
|
||||
|
||||
this.getCommand("ping").setExecutor(new PingCommand());
|
||||
this.getCommand("bing").setExecutor(new BingCommand());
|
||||
|
||||
}
|
||||
|
||||
if (this.getConfig().getBoolean("RanksMenu")) {
|
||||
|
||||
this.getCommand("ranks").setExecutor(new RanksCommand());
|
||||
|
||||
}
|
||||
|
||||
if (this.getConfig().getBoolean("TogglePhantoms")) {
|
||||
@@ -182,14 +200,17 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new TogglePhantomsListener(), this);
|
||||
|
||||
this.getCommand("togglephantoms").setExecutor(new TogglePhantomsCommand());
|
||||
|
||||
}
|
||||
|
||||
if (this.getConfig().getBoolean("NoAdvancementsInCreative")) {
|
||||
|
||||
getServer().getPluginManager().registerEvents(new NoAdvancementsInCreativeListener(), this);
|
||||
|
||||
}
|
||||
|
||||
this.getCommand("utilities").setExecutor(new AboutCommand());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,50 +224,59 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
|
||||
this.getLogger()
|
||||
.severe("ERROR: Failed to register the can-flippy Flag with WorldGuard. " + error.getMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
PlaceholderUtils.unregisterAll();
|
||||
|
||||
}
|
||||
|
||||
static FileConfiguration config() {
|
||||
|
||||
return config;
|
||||
|
||||
}
|
||||
|
||||
static String prefix() {
|
||||
|
||||
return "&7[&6Utilities&f-&4OG&7] ";
|
||||
|
||||
}
|
||||
|
||||
static StateFlag flippyFlag() {
|
||||
|
||||
return FlippyFlag;
|
||||
|
||||
}
|
||||
|
||||
static File phantomDisabledPlayersFile() {
|
||||
|
||||
return phantomPreferencesFile;
|
||||
|
||||
}
|
||||
|
||||
static YamlConfiguration phantomPreferences() {
|
||||
|
||||
return phantomPreferences;
|
||||
|
||||
}
|
||||
|
||||
// Unified method for sending a message to a player with placeholders processed.
|
||||
public static void trueogMessage(Player player, String message) {
|
||||
|
||||
TextUtils.trueogMessage(player, message);
|
||||
|
||||
}
|
||||
|
||||
// Handle messages to offline players (based on UUID).
|
||||
public static void trueogMessage(UUID playerUUID, String message) {
|
||||
|
||||
Player player = Bukkit.getPlayer(playerUUID);
|
||||
final Player player = Bukkit.getPlayer(playerUUID);
|
||||
if (player != null) {
|
||||
|
||||
TextUtils.trueogMessage(player, message);
|
||||
@@ -254,13 +284,16 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
} else {
|
||||
|
||||
logToConsole("[Utilities-OG]", "Player with UUID " + playerUUID + " is not online.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Formats a message without MiniPlaceholder expansion.
|
||||
public static TextComponent trueogColorize(String message) {
|
||||
|
||||
return (TextComponent) MiniMessage.miniMessage().deserialize(TextUtils.processColorCodes(message));
|
||||
|
||||
}
|
||||
|
||||
// Expands Global MiniPlaceholders.
|
||||
@@ -268,6 +301,7 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
|
||||
// MiniPlaceholder expansion with legacy and modern formatting.
|
||||
return TextUtils.expandTextWithPlaceholders(message);
|
||||
|
||||
}
|
||||
|
||||
// Expands Audience MiniPlaceholders.
|
||||
@@ -275,6 +309,7 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
|
||||
// MiniPlaceholder expansion with legacy and modern formatting.
|
||||
return TextUtils.expandTextWithPlaceholders(message, player);
|
||||
|
||||
}
|
||||
|
||||
// Expands Relational MiniPlaceholders.
|
||||
@@ -282,12 +317,13 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
|
||||
// MiniPlaceholder expansion with legacy and modern formatting.
|
||||
return TextUtils.expandTextWithPlaceholders(message, player, target);
|
||||
|
||||
}
|
||||
|
||||
// Variation of MiniPlaceholder expansion for when Bukkit API is unavailable.
|
||||
public static TextComponent trueogExpand(String message, UUID playerUUID) {
|
||||
|
||||
Player player = Bukkit.getPlayer(playerUUID);
|
||||
final Player player = Bukkit.getPlayer(playerUUID);
|
||||
if (player != null) {
|
||||
|
||||
return TextUtils.expandTextWithPlaceholders(message, player);
|
||||
@@ -297,79 +333,105 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
logToConsole("[Utilities-OG]", "Player with UUID " + playerUUID + " is not online.");
|
||||
|
||||
return TextUtils.expandTextWithPlaceholders(message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Global placeholder without arguments.
|
||||
public static void registerGlobalPlaceholder(String name, Supplier<String> valueSupplier) {
|
||||
|
||||
PlaceholderUtils.trueogRegisterMiniPlaceholder(name, placeholder -> {
|
||||
|
||||
placeholder.setGlobalPlaceholder(valueSupplier);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Global placeholder with arguments.
|
||||
public static void registerGlobalPlaceholder(String name, Function<List<String>, String> valueFunction) {
|
||||
|
||||
PlaceholderUtils.trueogRegisterMiniPlaceholder(name, placeholder -> {
|
||||
|
||||
placeholder.setGlobalPlaceholder(valueFunction);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Audience placeholder without arguments.
|
||||
public static void registerAudiencePlaceholder(String name, Function<Player, String> valueFunction) {
|
||||
|
||||
PlaceholderUtils.trueogRegisterMiniPlaceholder(name, placeholder -> {
|
||||
|
||||
placeholder.setAudiencePlaceholder(valueFunction);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Audience placeholder with arguments.
|
||||
public static void registerAudiencePlaceholder(
|
||||
String name, BiFunction<Player, List<String>, String> valueFunction) {
|
||||
public static void registerAudiencePlaceholder(String name,
|
||||
BiFunction<Player, List<String>, String> valueFunction)
|
||||
{
|
||||
|
||||
PlaceholderUtils.trueogRegisterMiniPlaceholder(name, placeholder -> {
|
||||
|
||||
placeholder.setAudiencePlaceholder(valueFunction);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Relational placeholder without arguments.
|
||||
public static void registerRelationalPlaceholder(String name, BiFunction<Player, Player, String> valueFunction) {
|
||||
|
||||
PlaceholderUtils.trueogRegisterMiniPlaceholder(name, placeholder -> {
|
||||
|
||||
placeholder.setRelationalPlaceholder(valueFunction);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Relational placeholder with arguments.
|
||||
public static void registerRelationalPlaceholder(
|
||||
String name, TriFunction<Player, Player, List<String>, String> valueFunction) {
|
||||
public static void registerRelationalPlaceholder(String name,
|
||||
TriFunction<Player, Player, List<String>, String> valueFunction)
|
||||
{
|
||||
|
||||
PlaceholderUtils.trueogRegisterMiniPlaceholder(name, placeholder -> {
|
||||
|
||||
placeholder.setRelationalPlaceholder(valueFunction);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// API to strip legacy and modern formatting in Strings.
|
||||
public static String stripFormatting(String content) {
|
||||
|
||||
return TextUtils.stripColors(content);
|
||||
|
||||
}
|
||||
|
||||
// Console logging API that automatically strips legacy and modern formatting.
|
||||
public static void logToConsole(String prefix, String message) {
|
||||
|
||||
Bukkit.getLogger().info(TextUtils.stripColors(prefix + " " + message));
|
||||
|
||||
}
|
||||
|
||||
public static UtilitiesOG getPlugin() {
|
||||
|
||||
return plugin;
|
||||
|
||||
}
|
||||
|
||||
public static BukkitTask runTaskAsynchronously(final Runnable run) {
|
||||
|
||||
return getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), run);
|
||||
|
||||
}
|
||||
|
||||
// Functional interface to support TriFunction.
|
||||
@@ -377,5 +439,7 @@ public final class UtilitiesOG extends JavaPlugin {
|
||||
public interface TriFunction<T, U, V, R> {
|
||||
|
||||
R apply(T t, U u, V v);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,14 +2,15 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.commands;
|
||||
|
||||
// Import libraries.
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
// Import libraries.
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
|
||||
// Declare the About Module with Bukkit Commands.
|
||||
public class AboutCommand implements CommandExecutor {
|
||||
|
||||
@@ -17,21 +18,18 @@ public class AboutCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
// Store the required permission for the "about" (root /utilities) command for later reference.
|
||||
String aboutPermission = "utilities.about";
|
||||
// Store the required permission for the "about" (root /utilities) command for
|
||||
// later reference.
|
||||
final String aboutPermission = "utilities.about";
|
||||
|
||||
// If the command was sent by an in-game player, do this...
|
||||
if (sender instanceof Player) {
|
||||
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
// If the player has permission to use /about, do this...
|
||||
if (player.hasPermission(aboutPermission)) {
|
||||
|
||||
// Send a formatted about message to the player using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#FFAA00>A collection of utilities and APIs used by <#00AA00>True<#AA0000>OG<#FFAA00> <#FFFF55>Network<#FFAA00>. Developed by <#FFFF55>christianniehaus <#FFAA00>& <#FFFF55>NotAlexNoyle<#FFAA00>.");
|
||||
|
||||
}
|
||||
@@ -40,6 +38,7 @@ public class AboutCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed, formatted permissions error message to the player.
|
||||
TextUtils.permissionsErrorMessage(player, cmd.getName(), aboutPermission);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,9 +47,12 @@ public class AboutCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed error message to the server console.
|
||||
TextUtils.logToConsole(cmd.getName() + " " + aboutPermission);
|
||||
|
||||
}
|
||||
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,14 +2,15 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.commands;
|
||||
|
||||
// Import libraries.
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
// Import libraries.
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
|
||||
// Declare the /bing command in the Ping Module with Bukkit Commands.
|
||||
public class BingCommand implements CommandExecutor {
|
||||
|
||||
@@ -18,18 +19,16 @@ public class BingCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
// Store the required permission for the /ping command for later reference.
|
||||
String pingPermission = "utilities.ping";
|
||||
final String pingPermission = "utilities.ping";
|
||||
|
||||
// If the command was sent by an in-game player, do this...
|
||||
if (sender instanceof Player) {
|
||||
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
// If the player has permission to use the Ping Module, do this...
|
||||
if (player.hasPermission(pingPermission)) {
|
||||
|
||||
// Send player a connection confirmation message with formatting using the TrueOG Message API.
|
||||
// Send player a connection confirmation message with formatting using the
|
||||
// TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(player, "<#FFFFFF> Bong!");
|
||||
|
||||
}
|
||||
@@ -38,6 +37,7 @@ public class BingCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed, formatted permissions error message to the player.
|
||||
TextUtils.permissionsErrorMessage(player, cmd.getName(), pingPermission);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,9 +46,12 @@ public class BingCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed error message to the server console.
|
||||
TextUtils.logToConsole(cmd.getName() + " " + pingPermission);
|
||||
|
||||
}
|
||||
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,14 +2,15 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.commands;
|
||||
|
||||
// Import libraries.
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
// Import libraries.
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
|
||||
// Declare the ColorCodes Module with Bukkit Commands.
|
||||
public class ColorCodesCommand implements CommandExecutor {
|
||||
|
||||
@@ -21,29 +22,28 @@ public class ColorCodesCommand implements CommandExecutor {
|
||||
|
||||
// Forwards the class instance to the caller.
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
// Command execution event handler using Bukkit's CommandManager.
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
// Store the required permission for the /colorcodes command for later reference.
|
||||
String colorCodesPermission = "utilities.colorcodes";
|
||||
// Store the required permission for the /colorcodes command for later
|
||||
// reference.
|
||||
final String colorCodesPermission = "utilities.colorcodes";
|
||||
|
||||
// If the command was sent by an in-game player, do this...
|
||||
if (sender instanceof Player) {
|
||||
|
||||
// Cast the sender to a player object safely.
|
||||
Player player = (Player) sender;
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
// If the player has permission to use /colorcodes, do this...
|
||||
if (player.hasPermission(colorCodesPermission)) {
|
||||
|
||||
// Send the color code cheat sheet to the player.
|
||||
// Uses MiniMessage directly so that the legacy color codes in the key are not processed.
|
||||
player.sendMessage(
|
||||
MiniMessage.miniMessage()
|
||||
.deserialize(
|
||||
"<dark_aqua><bold>-=-=-=-=- <dark_purple>C<dark_aqua>o<green>l<yellow>o<red>r <aqua>C<light_purple>o<white>d<light_purple>e<aqua>s: -=-=-=-=-"));
|
||||
// Uses MiniMessage directly so that the legacy color codes in the key are not
|
||||
// processed.
|
||||
player.sendMessage(MiniMessage.miniMessage().deserialize(
|
||||
"<dark_aqua><bold>-=-=-=-=- <dark_purple>C<dark_aqua>o<green>l<yellow>o<red>r <aqua>C<light_purple>o<white>d<light_purple>e<aqua>s: -=-=-=-=-"));
|
||||
player.sendMessage(MiniMessage.miniMessage()
|
||||
.deserialize("&0 = <black>Black <reset> &1 = <dark_blue>Dark Blue"));
|
||||
player.sendMessage(MiniMessage.miniMessage()
|
||||
@@ -73,6 +73,7 @@ public class ColorCodesCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed, formatted permissions error message to the player.
|
||||
TextUtils.permissionsErrorMessage(player, cmd.getName(), colorCodesPermission);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -81,9 +82,12 @@ public class ColorCodesCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed error message to the server console.
|
||||
TextUtils.logToConsole(cmd.getName() + " " + colorCodesPermission);
|
||||
|
||||
}
|
||||
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,15 +2,16 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.commands;
|
||||
|
||||
// Import libraries.
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
// Import libraries.
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
|
||||
// Declare the /ping command in the Ping Module with Bukkit Commands.
|
||||
public class PingCommand implements CommandExecutor {
|
||||
|
||||
@@ -19,13 +20,10 @@ public class PingCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
// Store the required permission for the /ping command for later reference.
|
||||
String pingPermission = "utilities.ping";
|
||||
final String pingPermission = "utilities.ping";
|
||||
|
||||
// If the command was sent by an in-game player, do this...
|
||||
if (sender instanceof Player) {
|
||||
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
// If the player has permission to use /ping, do this...
|
||||
if (player.hasPermission(pingPermission)) {
|
||||
@@ -34,8 +32,7 @@ public class PingCommand implements CommandExecutor {
|
||||
if (args.length == 0) {
|
||||
|
||||
// Send player their own ping with formatting using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#00AA00>Your current ping is: <#FFAA00>"
|
||||
+ player.getPing() + "<#00AA00>."));
|
||||
|
||||
@@ -44,14 +41,14 @@ public class PingCommand implements CommandExecutor {
|
||||
else if (args.length == 1) {
|
||||
|
||||
// Try to get the player that was specified.
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
final Player target = Bukkit.getPlayer(args[0]);
|
||||
|
||||
// If the provided argument was a valid player, do this...
|
||||
if (target != null) {
|
||||
|
||||
// Send player their specified player's ping with formatting using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
// Send player their specified player's ping with formatting using the TrueOG
|
||||
// Message API.
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#00AA00>" + target.getName()
|
||||
+ "'s current ping is: <#FFAA00>" + target.getPing() + "<#00AA00>."));
|
||||
|
||||
@@ -59,21 +56,23 @@ public class PingCommand implements CommandExecutor {
|
||||
// If the provided argument was not a valid player, do this...
|
||||
else {
|
||||
|
||||
// Send a "player not found" error message with formatting using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
// Send a "player not found" error message with formatting using the TrueOG
|
||||
// Message API.
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#AA0000> ERROR: The player "
|
||||
+ args[0] + " was not found!"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// If there is more than one provided argument, do this...
|
||||
else {
|
||||
|
||||
// Send a "too many arguments" error message with formatting using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
// Send a "too many arguments" error message with formatting using the TrueOG
|
||||
// Message API.
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#AA0000> ERROR: Too many arguments provided. Syntax: <#FFFF55>/ping <player>"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -82,6 +81,7 @@ public class PingCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed, formatted permissions error message to the player.
|
||||
TextUtils.permissionsErrorMessage(player, cmd.getName(), pingPermission);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -90,9 +90,12 @@ public class PingCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed error message to the server console.
|
||||
TextUtils.logToConsole(cmd.getName() + " " + pingPermission);
|
||||
|
||||
}
|
||||
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,15 +2,16 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
// Declare the Ranks Module with Bukkit Commands.
|
||||
public class RanksCommand implements CommandExecutor {
|
||||
@@ -20,13 +21,10 @@ public class RanksCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
// Store the required permission for the /ranks command for later reference.
|
||||
String ranksPermission = "utilities.ranks";
|
||||
final String ranksPermission = "utilities.ranks";
|
||||
|
||||
// If the command was sent by an in-game player, do this...
|
||||
if (sender instanceof Player) {
|
||||
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
// If the player has permission to use /ranks, do this...
|
||||
if (player.hasPermission(ranksPermission)) {
|
||||
@@ -34,29 +32,26 @@ public class RanksCommand implements CommandExecutor {
|
||||
// If the player did not provide any arguments, do this...
|
||||
if (args.length == 0) {
|
||||
|
||||
// Send the available ranks to the player, with clickable menus to get more information about each
|
||||
// Send the available ranks to the player, with clickable menus to get more
|
||||
// information about each
|
||||
// rank.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<bold><dark_purple>-=-=-=-=- <dark_green>True<dark_red>OG <aqua>Donation Store: <dark_purple>-=-=-=-=-");
|
||||
UtilitiesOG.trueogMessage(player, "");
|
||||
UtilitiesOG.trueogMessage(player, "Each donor rank requires the rank before it.");
|
||||
UtilitiesOG.trueogMessage(player, "");
|
||||
UtilitiesOG.trueogMessage(
|
||||
player, "<green>Rank Overview: <dark_aqua><underlined>https://shop.true-og.net");
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<green>Rank Overview: <dark_aqua><underlined>https://shop.true-og.net");
|
||||
UtilitiesOG.trueogMessage(player, "");
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<white>[OG] <gray>(<dark_green>$10 Once<gray>) <dark_aqua><underlined>https://true-og.net/og");
|
||||
sendClickableMessage(player, "/ranks og");
|
||||
UtilitiesOG.trueogMessage(player, "");
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<red>[OG Pro] <gray>(<dark_green>$50 Once<gray>) <dark_aqua><underlined>https://true-og.net/og-pro");
|
||||
sendClickableMessage(player, "/ranks og-pro");
|
||||
UtilitiesOG.trueogMessage(player, "");
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<dark_red><bold>[OG Master] <gray>(<gold>$10 Monthly<gray>) <dark_aqua><underlined>https://true-og.net/og-master");
|
||||
sendClickableMessage(player, "/ranks og-master");
|
||||
|
||||
@@ -67,17 +62,16 @@ public class RanksCommand implements CommandExecutor {
|
||||
// If the "OG" message was clicked, do this...
|
||||
if (args[0].equalsIgnoreCase("og")) {
|
||||
|
||||
// Share "OG" benefits with the player with formatting using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
// Share "OG" benefits with the player with formatting using the TrueOG Message
|
||||
// API.
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<dark_purple><bold>-=-=-=-=- <dark_green>True<dark_red>OG <white>OG Rank: <dark_purple>-=-=-=-=-");
|
||||
UtilitiesOG.trueogMessage(player, "- Use /afk for an unlimited amount of time.");
|
||||
UtilitiesOG.trueogMessage(player, "- Prominent white chat prefix");
|
||||
UtilitiesOG.trueogMessage(player, "- Create unions with /union create.");
|
||||
UtilitiesOG.trueogMessage(player, "- Invite people to unions with /union invite.");
|
||||
UtilitiesOG.trueogMessage(player, "- Access to #donor-chat on Discord.");
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"- 6 homes (temporary benefit until the implementation of our in-game home earning plugin).");
|
||||
UtilitiesOG.trueogMessage(player, "- &lMore TBA&r.");
|
||||
|
||||
@@ -85,41 +79,41 @@ public class RanksCommand implements CommandExecutor {
|
||||
// If the "OG Pro" message was clicked, do this...
|
||||
else if (args[0].equalsIgnoreCase("og-pro")) {
|
||||
|
||||
// Share "OG Pro" benefits with the player with formatting using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
// Share "OG Pro" benefits with the player with formatting using the TrueOG
|
||||
// Message API.
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<dark_purple><bold>-=-=-=-=- <dark_green>True&<dark_red>OG <red>OG Pro Rank: <dark_purple>-=-=-=-=-");
|
||||
UtilitiesOG.trueogMessage(player, "- &lAll OG Benefits&r.");
|
||||
UtilitiesOG.trueogMessage(player, "- Rent up to 2 shops at the player market.");
|
||||
UtilitiesOG.trueogMessage(player, "- Special chat formatting (bold, italics, magic, etc).");
|
||||
UtilitiesOG.trueogMessage(
|
||||
player, "- Use color codes in chat, mail, unions, signs, anvils, and book titles.");
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"- Use color codes in chat, mail, unions, signs, anvils, and book titles.");
|
||||
UtilitiesOG.trueogMessage(player, "- Edit written books with /book.");
|
||||
UtilitiesOG.trueogMessage(player, "- Edit signs with /editsign.");
|
||||
UtilitiesOG.trueogMessage(player, "- Wear hats with /hat.");
|
||||
UtilitiesOG.trueogMessage(player, "- Sit anywhere with /sit.");
|
||||
UtilitiesOG.trueogMessage(player, "- Access your ender chest anywhere with /echest.");
|
||||
UtilitiesOG.trueogMessage(
|
||||
player, "- Use 9 exclusive particle cosmetics with /cosmetics (up to 3 at once).");
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"- Use 9 exclusive particle cosmetics with /cosmetics (up to 3 at once).");
|
||||
UtilitiesOG.trueogMessage(player, "- &lMore TBA&r.");
|
||||
|
||||
}
|
||||
// If the "OG Master" message was clicked, do this...
|
||||
else if (args[0].equalsIgnoreCase("og-master")) {
|
||||
|
||||
// Share "OG Master" benefits with the player with formatting using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
// Share "OG Master" benefits with the player with formatting using the TrueOG
|
||||
// Message API.
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<dark_purple><bold>-=-=-=-=- <dark_green>True<dark_red>OG <dark_red>OG Master Rank: <dark_purple>-=-=-=-=-");
|
||||
UtilitiesOG.trueogMessage(player, "- &lAll OG and OG Pro Benefits&r.");
|
||||
UtilitiesOG.trueogMessage(player, "- Rent up to 3 shops at the player market.");
|
||||
UtilitiesOG.trueogMessage(player, "- &lWorld inspection &rwith /co inspect.");
|
||||
UtilitiesOG.trueogMessage(player, "- Return to last teleport destination with /back.");
|
||||
UtilitiesOG.trueogMessage(player, "- Toggle your death coordinates in chat with /tdc.");
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"- Special mail, sign, and anvil formatting (strike-through, italics, magic, etc).");
|
||||
UtilitiesOG.trueogMessage(player, "- &lMore TBA&r.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,9 +121,9 @@ public class RanksCommand implements CommandExecutor {
|
||||
else {
|
||||
|
||||
// Send the player a formatted error message using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<gray>[<dark_green>True<dark_red>OG<gray>] <red>ERROR: Too many arguments! <gold>Syntax: <yellow>/ranks");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -138,6 +132,7 @@ public class RanksCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed, formatted permissions error message to the player.
|
||||
TextUtils.permissionsErrorMessage(player, cmd.getName(), ranksPermission);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -146,23 +141,28 @@ public class RanksCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed error message to the server console.
|
||||
TextUtils.logToConsole(cmd.getName() + " " + ranksPermission);
|
||||
|
||||
}
|
||||
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Turns chat text into a command button.
|
||||
public static void sendClickableMessage(Player player, String command) {
|
||||
|
||||
// Declare a TextComponent with pre-formatted contents using standard MiniMessage APi.
|
||||
TextComponent clickableText =
|
||||
(TextComponent) MiniMessage.miniMessage().deserialize("<aqua><bold>Click here to see the benefits!");
|
||||
// Declare a TextComponent with pre-formatted contents using standard
|
||||
// MiniMessage APi.
|
||||
TextComponent clickableText = (TextComponent) MiniMessage.miniMessage()
|
||||
.deserialize("<aqua><bold>Click here to see the benefits!");
|
||||
|
||||
// Create a click event on the chat text.
|
||||
clickableText = clickableText.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, command));
|
||||
|
||||
// Send the clickable text to the player.
|
||||
player.sendMessage(clickableText);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,15 +2,16 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.commands;
|
||||
|
||||
// Import libraries.
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
// Import libraries.
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
|
||||
// Declare the /togglecramming command in the DisableEntityCramming Module with Bukkit Commands.
|
||||
public class ToggleCrammingCommand implements CommandExecutor {
|
||||
|
||||
@@ -18,26 +19,24 @@ public class ToggleCrammingCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
// Store the required permission for the /togglecramming command for later reference.
|
||||
String toggleCrammingPermission = "utilities.togglecramming";
|
||||
// Store the required permission for the /togglecramming command for later
|
||||
// reference.
|
||||
final String toggleCrammingPermission = "utilities.togglecramming";
|
||||
|
||||
// If the command executor is a player, do this...
|
||||
if (sender instanceof Player) {
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
// If the command runner has permission to toggle entity cramming, do this...
|
||||
if (player.hasPermission(toggleCrammingPermission)) {
|
||||
|
||||
// Fetch config file from data folder.
|
||||
FileConfiguration config = UtilitiesOG.getPlugin().getConfig();
|
||||
final FileConfiguration config = UtilitiesOG.getPlugin().getConfig();
|
||||
|
||||
// Flip the true/false value to the opposite of what it currently is.
|
||||
config.set("doEntityCramming", !config.getBoolean("doEntityCramming"));
|
||||
|
||||
// Send confirmation message with formatting using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#FFAA00>Entity cramming has been set to <#FFFF55>"
|
||||
+ config.getBoolean("doEntityCramming") + "<#FFAA00>."));
|
||||
|
||||
@@ -47,6 +46,7 @@ public class ToggleCrammingCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed, formatted permissions error message to the player.
|
||||
TextUtils.permissionsErrorMessage(player, cmd.getName(), toggleCrammingPermission);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,9 +55,12 @@ public class ToggleCrammingCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed error message to the server console.
|
||||
TextUtils.logToConsole(cmd.getName() + " " + toggleCrammingPermission);
|
||||
|
||||
}
|
||||
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,15 +4,17 @@ package net.trueog.utilitiesog.commands;
|
||||
|
||||
// Import libraries.
|
||||
import java.io.IOException;
|
||||
import net.trueog.utilitiesog.InternalFunctions;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.trueog.utilitiesog.InternalFunctions;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.utils.TextUtils;
|
||||
|
||||
// Declare the /togglephantoms command in the Ping Module with Bukkit Commands.
|
||||
public class TogglePhantomsCommand implements CommandExecutor {
|
||||
|
||||
@@ -20,24 +22,21 @@ public class TogglePhantomsCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
// Store the required permission for the /togglephantoms command for later reference.
|
||||
String togglePhantomsPermission = "utilities.togglephantoms";
|
||||
// Store the required permission for the /togglephantoms command for later
|
||||
// reference.
|
||||
final String togglePhantomsPermission = "utilities.togglephantoms";
|
||||
|
||||
// If the command was sent by an in-game player, do this...
|
||||
if (sender instanceof Player) {
|
||||
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
// If the player has permission to use /togglephantoms, do this...
|
||||
if (player.hasPermission(togglePhantomsPermission)) {
|
||||
|
||||
// Store the contents of phantomDisabledUsers.yml file as a YAML object.
|
||||
YamlConfiguration phantomPreferences = InternalFunctions.getPhantomPreferences();
|
||||
final YamlConfiguration phantomPreferences = InternalFunctions.getPhantomPreferences();
|
||||
|
||||
// Cherry pick the command runner's phantom status from the YAML data set.
|
||||
boolean phantomToggleState =
|
||||
phantomPreferences.getBoolean(player.getUniqueId().toString());
|
||||
final boolean phantomToggleState = phantomPreferences.getBoolean(player.getUniqueId().toString());
|
||||
|
||||
// Flip the true/false value to the opposite of what it currently is.
|
||||
phantomPreferences.set(player.getUniqueId().toString(), !phantomToggleState);
|
||||
@@ -46,18 +45,18 @@ public class TogglePhantomsCommand implements CommandExecutor {
|
||||
if (phantomToggleState) {
|
||||
|
||||
// Send a formatted "true" message with formatting using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#55FF55>Phantom spawning turned <#00AA00>ON<#55FF55>.");
|
||||
|
||||
}
|
||||
// If the command sender's phantom spawning is turned off, do this...
|
||||
else {
|
||||
|
||||
// Send a formatted "false" message with formatting using the TrueOG Message API.
|
||||
UtilitiesOG.trueogMessage(
|
||||
player,
|
||||
// Send a formatted "false" message with formatting using the TrueOG Message
|
||||
// API.
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#FFAA00>Phantom spawning turned <#FF5555>OFF<#FFAA00>.");
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -69,6 +68,7 @@ public class TogglePhantomsCommand implements CommandExecutor {
|
||||
|
||||
// Throw a runtime error if the YAML data could not be saved to disk.
|
||||
throw new RuntimeException(error);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -77,6 +77,7 @@ public class TogglePhantomsCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed, formatted permissions error message to the player.
|
||||
TextUtils.permissionsErrorMessage(player, cmd.getName(), togglePhantomsPermission);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -85,9 +86,12 @@ public class TogglePhantomsCommand implements CommandExecutor {
|
||||
|
||||
// Send a detailed error message to the server console.
|
||||
TextUtils.logToConsole(cmd.getName() + " " + togglePhantomsPermission);
|
||||
|
||||
}
|
||||
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,12 +2,13 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.listeners;
|
||||
|
||||
import net.trueog.utilitiesog.InternalFunctions;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
import net.trueog.utilitiesog.InternalFunctions;
|
||||
|
||||
// Declare the EntityCrammingToggle Module with Bukkit Listeners.
|
||||
public class DisableEntityCrammingListener implements Listener {
|
||||
|
||||
@@ -15,15 +16,21 @@ public class DisableEntityCrammingListener implements Listener {
|
||||
@EventHandler
|
||||
public void disableEntityCramming(EntityDamageEvent event) {
|
||||
|
||||
// If the Disable Entity Cramming Module is enabled in config.yml, do this...
|
||||
// Cancel damage from entity cramming.
|
||||
// If the damage is caused by entity cramming, do this...
|
||||
if (event.getCause().equals(DamageCause.CRAMMING)) {
|
||||
if (event.getCause() == DamageCause.CRAMMING) {
|
||||
|
||||
// If the Disable Entity Cramming Module is enabled in config.yml, do this...
|
||||
if (InternalFunctions.getConfig().getBoolean("EntityCrammingDisable") == true) {
|
||||
|
||||
// Cancel damage from entity cramming.
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+10
-2
@@ -1,17 +1,25 @@
|
||||
package net.trueog.utilitiesog.listeners;
|
||||
// Import libraries.
|
||||
|
||||
import com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent;
|
||||
import net.trueog.utilitiesog.FastOfflinePlayer;
|
||||
import org.bukkit.GameMode;
|
||||
// Hook into Bukkit's Listener.
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class NoAdvancementsInCreativeListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onAdvancementProgress(PlayerAdvancementCriterionGrantEvent event) {
|
||||
|
||||
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL) {
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
final FastOfflinePlayer fop = new FastOfflinePlayer(event.getPlayer().getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,14 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.listeners;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
@@ -12,15 +20,10 @@ import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
|
||||
import net.trueog.utilitiesog.InternalFunctions;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import net.trueog.utilitiesog.misc.FlagRegistrationException;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
// Declare the NoFlippy Module with Bukkit Listeners.
|
||||
public class NoFlippyListener implements Listener {
|
||||
@@ -33,6 +36,7 @@ public class NoFlippyListener implements Listener {
|
||||
|
||||
// Pass back Listeners to main.
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
// Listen for a player interacting with a trap-door.
|
||||
@@ -40,17 +44,18 @@ public class NoFlippyListener implements Listener {
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
// Get the nature of the interaction and store it.
|
||||
Action action = event.getAction();
|
||||
final Action action = event.getAction();
|
||||
// Get the block that was interacted with and store it.
|
||||
Block blockClicked = event.getClickedBlock();
|
||||
final Block blockClicked = event.getClickedBlock();
|
||||
// Get the player who interacted and store them.
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
// Declare a container for the block type for null checking.
|
||||
String blockContainerAsString = null;
|
||||
try {
|
||||
|
||||
// Try storing the block type as a string. Throws NullPointerException if not applicable.
|
||||
// Try storing the block type as a string. Throws NullPointerException if not
|
||||
// applicable.
|
||||
blockContainerAsString = blockClicked.getType().toString();
|
||||
|
||||
}
|
||||
@@ -59,10 +64,11 @@ public class NoFlippyListener implements Listener {
|
||||
|
||||
// Do nothing.
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// If the interaction was with a trap door, do this...
|
||||
if (blockContainerAsString.contains("TRAPDOOR")) {
|
||||
if (StringUtils.contains(blockContainerAsString, "TRAPDOOR")) {
|
||||
|
||||
// If the interaction was a right click, do this...
|
||||
if (action.isRightClick()) {
|
||||
@@ -71,39 +77,45 @@ public class NoFlippyListener implements Listener {
|
||||
if (!player.hasPermission("noflippy.bypass")) {
|
||||
|
||||
// Get the location of the block the player tried to flip.
|
||||
Location blockLocation = BukkitAdapter.adapt(blockClicked.getLocation());
|
||||
final Location blockLocation = BukkitAdapter.adapt(blockClicked.getLocation());
|
||||
|
||||
// Instantiate a WorldGuard Region Container.
|
||||
RegionContainer container =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
final RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
|
||||
// Instantiate a WorldGuard Region Query.
|
||||
RegionQuery query = container.createQuery();
|
||||
final RegionQuery query = container.createQuery();
|
||||
|
||||
// Get all regions at the location of the block.
|
||||
ApplicableRegionSet set = query.getApplicableRegions(blockLocation);
|
||||
final ApplicableRegionSet set = query.getApplicableRegions(blockLocation);
|
||||
|
||||
// If the can-flippy WorldGuard Flag is set to DENY, for any region in the set, do this...
|
||||
// If the can-flippy WorldGuard Flag is set to DENY, for any region in the set,
|
||||
// do this...
|
||||
if (!set.testState(null, InternalFunctions.getFlippyFlag())) {
|
||||
|
||||
// Cancel the trapdoor flip event.
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Registers the WorldGuard Flag "can-flippy". Throws a custom exception in case of error.
|
||||
// Registers the WorldGuard Flag "can-flippy". Throws a custom exception in case
|
||||
// of error.
|
||||
public static StateFlag registerNoFlippyWorldGuardFlag(StateFlag FlippyFlags) throws FlagRegistrationException {
|
||||
|
||||
// Add the WorldGuard flag for an area where NoFlippy is active.
|
||||
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||
final FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||
|
||||
try {
|
||||
|
||||
// Create a flag with the name "my-custom-flag", defaulting to true.
|
||||
StateFlag flag = new StateFlag("can-flippy", true);
|
||||
final StateFlag flag = new StateFlag("can-flippy", true);
|
||||
|
||||
// Register the new flag with WorldGuard.
|
||||
registry.register(flag);
|
||||
@@ -116,14 +128,14 @@ public class NoFlippyListener implements Listener {
|
||||
catch (FlagConflictException error) {
|
||||
|
||||
// Log the WorldGuard Flag conflict to the server console.
|
||||
UtilitiesOG.getPlugin()
|
||||
.getLogger()
|
||||
.severe("ERROR: can-flippy of the NoFlippy Module has a WorldGuard Flag conflict! "
|
||||
+ error.getMessage());
|
||||
UtilitiesOG.getPlugin().getLogger().severe(
|
||||
"ERROR: can-flippy of the NoFlippy Module has a WorldGuard Flag conflict! " + error.getMessage());
|
||||
|
||||
// Pulls the WorldGuard Flag from the registry that some other plugin registered by the same name.
|
||||
// Developer Note: You CAN use the existing flag, but this may cause conflicts - be sure to check type.
|
||||
Flag<?> existing = registry.get("can-flippy");
|
||||
// Pulls the WorldGuard Flag from the registry that some other plugin registered
|
||||
// by the same name.
|
||||
// Developer Note: You CAN use the existing flag, but this may cause conflicts -
|
||||
// be sure to check type.
|
||||
final Flag<?> existing = registry.get("can-flippy");
|
||||
// If the existing WorldGuard Flag is a StateFlag, do this...
|
||||
if (existing instanceof StateFlag) {
|
||||
|
||||
@@ -134,10 +146,15 @@ public class NoFlippyListener implements Listener {
|
||||
// If the existing WorldGuard Flag is not a StateFlag, do this...
|
||||
else {
|
||||
|
||||
// Throw a custom exception that displays details about the issues with flag registration in the server
|
||||
// Throw a custom exception that displays details about the issues with flag
|
||||
// registration in the server
|
||||
// console.
|
||||
throw new FlagRegistrationException("Failed to register can-flippy flag due to conflict.", error);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.listeners;
|
||||
|
||||
import net.trueog.utilitiesog.InternalFunctions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -11,6 +10,8 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
import net.trueog.utilitiesog.InternalFunctions;
|
||||
|
||||
// Declare the DisablePhantomSpawns Module with Bukkit Listeners.
|
||||
public class TogglePhantomsListener implements Listener {
|
||||
|
||||
@@ -19,24 +20,32 @@ public class TogglePhantomsListener implements Listener {
|
||||
public void disablePhantomSpawns(CreatureSpawnEvent event) {
|
||||
|
||||
// If the mob that spawned is a phantom, do this...
|
||||
if (event.getEntityType().equals(EntityType.PHANTOM)) {
|
||||
if (!event.getEntityType().equals(EntityType.PHANTOM)) {
|
||||
|
||||
// Store the contents of phantomDisabledUsers.yml file as a YAML object.
|
||||
YamlConfiguration phantomsAreDisabled = InternalFunctions.getPhantomPreferences();
|
||||
return;
|
||||
|
||||
// Get every player currently on the server in the world where the phantom spawned.
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers().stream()
|
||||
.filter(p -> p.getWorld().equals(event.getEntity().getWorld()))
|
||||
.filter(p -> phantomsAreDisabled.getBoolean(p.getUniqueId().toString()))
|
||||
.toArray(Player[]::new)) {
|
||||
|
||||
// Check if the phantom is close enough to the player to count as being their spawn.
|
||||
if (event.getEntity().getLocation().distance(player.getLocation()) < 48) {
|
||||
|
||||
// Prevent the phantom from spawning.
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store the contents of phantomDisabledUsers.yml file as a YAML object.
|
||||
final YamlConfiguration phantomsAreDisabled = InternalFunctions.getPhantomPreferences();
|
||||
// Get every player currently on the server in the world where the phantom
|
||||
// spawned.
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers().stream()
|
||||
.filter(p -> p.getWorld().equals(event.getEntity().getWorld()))
|
||||
.filter(p -> phantomsAreDisabled.getBoolean(p.getUniqueId().toString())).toArray(Player[]::new))
|
||||
{
|
||||
|
||||
// Check if the phantom is close enough to the player to count as being their
|
||||
// spawn.
|
||||
if (event.getEntity().getLocation().distance(player.getLocation()) < 48) {
|
||||
|
||||
// Prevent the phantom from spawning.
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,23 +87,29 @@ public class ColorCodeMap {
|
||||
|
||||
// Reset all formatting.
|
||||
CODE_MAP.put('r', "<reset>");
|
||||
|
||||
}
|
||||
|
||||
// Convert any lowercase Bukkit color / formatting code to a modern MiniMessage color / formatting code.
|
||||
// Convert any lowercase Bukkit color / formatting code to a modern MiniMessage
|
||||
// color / formatting code.
|
||||
public static String toMiniMessage(char legacyCode) {
|
||||
|
||||
// Use the Bukkit color / formatting code as a key to get the modern MiniMessage color / formatting code from
|
||||
// Use the Bukkit color / formatting code as a key to get the modern MiniMessage
|
||||
// color / formatting code from
|
||||
// the Hash Map.
|
||||
String miniMessageCode = CODE_MAP.get(legacyCode);
|
||||
final String miniMessageCode = CODE_MAP.get(legacyCode);
|
||||
|
||||
// If the Bukkit color code is not in the Hash Map, do this...
|
||||
if (miniMessageCode == null) {
|
||||
|
||||
// Cause a NullPointerExceptionError for the caller to handle.
|
||||
throw new NullPointerException();
|
||||
|
||||
}
|
||||
|
||||
// If the Bukkit color code is in the Hash Map, do this...
|
||||
return miniMessageCode;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,8 @@ package net.trueog.utilitiesog.misc;
|
||||
// Declare a custom exception for the case where a WorldGuard Flag fails to register for internal use by Utilities-OG.
|
||||
public class FlagRegistrationException extends Exception {
|
||||
|
||||
// This ID is used when the exception is serialized (converted to a byte stream), for example when it's sent over a
|
||||
// This ID is used when the exception is serialized (converted to a byte
|
||||
// stream), for example when it's sent over a
|
||||
// network.
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -14,6 +15,7 @@ public class FlagRegistrationException extends Exception {
|
||||
|
||||
// Pass the basic message to the base Exception class.
|
||||
super(message);
|
||||
|
||||
}
|
||||
|
||||
// Constructor to handle sending an error message and a cause.
|
||||
@@ -21,5 +23,7 @@ public class FlagRegistrationException extends Exception {
|
||||
|
||||
// Pass the more informative message to the base Exception class.
|
||||
super(message, cause);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,13 +2,14 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.modules;
|
||||
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
// Declare the Chain Armor Module.
|
||||
public class ChainArmorModule {
|
||||
|
||||
@@ -16,37 +17,32 @@ public class ChainArmorModule {
|
||||
public static void Enable() {
|
||||
|
||||
// Defines a crafting recipe for Chainmail Helmet from Chains.
|
||||
ShapedRecipe ChainHelmet = new ShapedRecipe(
|
||||
new NamespacedKey(UtilitiesOG.getPlugin(), "Chainmail_Helmet1"),
|
||||
new ItemStack(Material.CHAINMAIL_HELMET))
|
||||
.shape("ccc", "c c")
|
||||
.setIngredient('c', Material.CHAIN);
|
||||
final ShapedRecipe ChainHelmet = new ShapedRecipe(
|
||||
new NamespacedKey(UtilitiesOG.getPlugin(), "Chainmail_Helmet1"),
|
||||
new ItemStack(Material.CHAINMAIL_HELMET)).shape("ccc", "c c").setIngredient('c', Material.CHAIN);
|
||||
|
||||
// Defines a crafting recipe for Chainmail Chestplate from Chains.
|
||||
ShapedRecipe ChainChestPlate = new ShapedRecipe(
|
||||
new NamespacedKey(UtilitiesOG.getPlugin(), "Chainmail_Chestplate"),
|
||||
new ItemStack(Material.CHAINMAIL_CHESTPLATE))
|
||||
.shape("c c", "ccc", "ccc")
|
||||
final ShapedRecipe ChainChestPlate = new ShapedRecipe(
|
||||
new NamespacedKey(UtilitiesOG.getPlugin(), "Chainmail_Chestplate"),
|
||||
new ItemStack(Material.CHAINMAIL_CHESTPLATE)).shape("c c", "ccc", "ccc")
|
||||
.setIngredient('c', Material.CHAIN);
|
||||
|
||||
// Defines a crafting recipe for Chainmail Leggings from Chains.
|
||||
ShapedRecipe ChainLeggings = new ShapedRecipe(
|
||||
new NamespacedKey(UtilitiesOG.getPlugin(), "Chainmail_Leggings"),
|
||||
new ItemStack(Material.CHAINMAIL_LEGGINGS))
|
||||
.shape("ccc", "c c", "c c")
|
||||
final ShapedRecipe ChainLeggings = new ShapedRecipe(
|
||||
new NamespacedKey(UtilitiesOG.getPlugin(), "Chainmail_Leggings"),
|
||||
new ItemStack(Material.CHAINMAIL_LEGGINGS)).shape("ccc", "c c", "c c")
|
||||
.setIngredient('c', Material.CHAIN);
|
||||
|
||||
// Defines a crafting recipe for Chainmail Boots from Chains.
|
||||
ShapedRecipe ChainBoots = new ShapedRecipe(
|
||||
new NamespacedKey(UtilitiesOG.getPlugin(), "Chainmail_Boots1"),
|
||||
new ItemStack(Material.CHAINMAIL_BOOTS))
|
||||
.shape("c c", "c c")
|
||||
.setIngredient('c', Material.CHAIN);
|
||||
final ShapedRecipe ChainBoots = new ShapedRecipe(new NamespacedKey(UtilitiesOG.getPlugin(), "Chainmail_Boots1"),
|
||||
new ItemStack(Material.CHAINMAIL_BOOTS)).shape("c c", "c c").setIngredient('c', Material.CHAIN);
|
||||
|
||||
// Add the Chainmail Armor crafting recipes to the server.
|
||||
Bukkit.addRecipe(ChainHelmet);
|
||||
Bukkit.addRecipe(ChainChestPlate);
|
||||
Bukkit.addRecipe(ChainLeggings);
|
||||
Bukkit.addRecipe(ChainBoots);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,10 +2,6 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.modules;
|
||||
|
||||
// Import libraries.
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -13,6 +9,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
// Import libraries.
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
// Declare the Mock Bamboo Wood Module.
|
||||
public class MockBambooModule {
|
||||
|
||||
@@ -20,10 +21,10 @@ public class MockBambooModule {
|
||||
public static void Enable() {
|
||||
|
||||
// Create a novel item, Bamboo Planks, based on Oak Planks.
|
||||
ItemStack bambooPlanks = new ItemStack(Material.OAK_PLANKS);
|
||||
final ItemStack bambooPlanks = new ItemStack(Material.OAK_PLANKS);
|
||||
|
||||
// Fetch the meta of the mock Bamboo Planks for editing.
|
||||
ItemMeta bambooPlanksMeta = bambooPlanks.getItemMeta();
|
||||
final ItemMeta bambooPlanksMeta = bambooPlanks.getItemMeta();
|
||||
|
||||
// Gives the mock Bamboo Planks a formatted title.
|
||||
bambooPlanksMeta.displayName(
|
||||
@@ -33,9 +34,8 @@ public class MockBambooModule {
|
||||
bambooPlanks.setItemMeta(bambooPlanksMeta);
|
||||
|
||||
// Defines a crafting recipe for Bamboo Planks.
|
||||
ShapedRecipe BambooPlanks = new ShapedRecipe(
|
||||
new NamespacedKey(UtilitiesOG.getPlugin(), "Bamboo_Planks"), bambooPlanks)
|
||||
.shape("bb", "bb")
|
||||
final ShapedRecipe BambooPlanks = new ShapedRecipe(new NamespacedKey(UtilitiesOG.getPlugin(), "Bamboo_Planks"),
|
||||
bambooPlanks).shape("bb", "bb")
|
||||
// Use Bamboo as the base ingredient.
|
||||
.setIngredient('b', Material.BAMBOO);
|
||||
|
||||
@@ -43,10 +43,10 @@ public class MockBambooModule {
|
||||
Bukkit.addRecipe(BambooPlanks);
|
||||
|
||||
// Create a novel item, Bamboo Wood, based on Birch Wood.
|
||||
ItemStack imitationBambooWood = new ItemStack(Material.BIRCH_WOOD);
|
||||
final ItemStack imitationBambooWood = new ItemStack(Material.BIRCH_WOOD);
|
||||
|
||||
// Fetch the meta of the mock Bamboo Wood for editing.
|
||||
ItemMeta imitationBambooWoodMeta = imitationBambooWood.getItemMeta();
|
||||
final ItemMeta imitationBambooWoodMeta = imitationBambooWood.getItemMeta();
|
||||
|
||||
// Gives the mock Bamboo Wood a formatted title.
|
||||
imitationBambooWoodMeta.displayName(
|
||||
@@ -56,13 +56,15 @@ public class MockBambooModule {
|
||||
imitationBambooWood.setItemMeta(imitationBambooWoodMeta);
|
||||
|
||||
// Define a crafting recipe for mock Bamboo Wood.
|
||||
ShapedRecipe imitationBambooWoodRecipe = new ShapedRecipe(
|
||||
new NamespacedKey(UtilitiesOG.getPlugin(), "Imitation_Bamboo_Wood"), imitationBambooWood)
|
||||
final ShapedRecipe imitationBambooWoodRecipe = new ShapedRecipe(
|
||||
new NamespacedKey(UtilitiesOG.getPlugin(), "Imitation_Bamboo_Wood"), imitationBambooWood)
|
||||
.shape("bb", "bb")
|
||||
// Use the previously created bamboo planks as the base ingredient.
|
||||
.setIngredient('b', bambooPlanks);
|
||||
|
||||
// Add the crafting recipe for mock Bamboo Wood to the server.
|
||||
Bukkit.addRecipe(imitationBambooWoodRecipe);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.trueog.utilitiesog.utils;
|
||||
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -9,12 +8,16 @@ import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.trueog.utilitiesog.InternalFunctions;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlaceholderUtils {
|
||||
|
||||
@@ -32,194 +35,216 @@ public class PlaceholderUtils {
|
||||
|
||||
this.miniPlaceholderPrefix = placeholderPrefix;
|
||||
this.miniPlaceholderSuffix = placeholderSuffix;
|
||||
|
||||
}
|
||||
|
||||
// Set global placeholder without arguments.
|
||||
public PlaceholderUtils setGlobalPlaceholder(Supplier<String> placeholder) {
|
||||
|
||||
this.placeholderRegistration = builder -> builder.globalPlaceholder(miniPlaceholderSuffix, (queue, ctx) -> {
|
||||
TextComponent result = TextUtils.expandTextWithPlaceholders(placeholder.get());
|
||||
|
||||
return Tag.inserting(result);
|
||||
});
|
||||
this.placeholderRegistration = builder -> builder.globalPlaceholder(miniPlaceholderSuffix,
|
||||
(queue, ctx) -> Tag.inserting(TextUtils.expandTextWithPlaceholders(placeholder.get())));
|
||||
|
||||
// Log global placeholder registration without arguments.
|
||||
UtilitiesOG.logToConsole(
|
||||
InternalFunctions.getPrefix(),
|
||||
"Registered Global MiniPlaceholder: " + miniPlaceholderPrefix + "_" + miniPlaceholderSuffix
|
||||
+ " without arguments");
|
||||
UtilitiesOG.logToConsole(InternalFunctions.getPrefix(), "Registered Global MiniPlaceholder: "
|
||||
+ miniPlaceholderPrefix + "_" + miniPlaceholderSuffix + " without arguments");
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
// Set global placeholder with arguments.
|
||||
public PlaceholderUtils setGlobalPlaceholder(Function<List<String>, String> valueFunction) {
|
||||
|
||||
this.placeholderRegistration = builder -> builder.globalPlaceholder(miniPlaceholderSuffix, (queue, ctx) -> {
|
||||
List<String> args = new ArrayList<>();
|
||||
|
||||
final List<String> args = new ArrayList<>();
|
||||
while (queue.hasNext()) {
|
||||
|
||||
args.add(queue.pop().value());
|
||||
|
||||
}
|
||||
|
||||
String resultString = valueFunction.apply(args);
|
||||
final String resultString = valueFunction.apply(args);
|
||||
|
||||
TextComponent result = TextUtils.expandTextWithPlaceholders(resultString);
|
||||
final TextComponent result = TextUtils.expandTextWithPlaceholders(resultString);
|
||||
|
||||
return Tag.inserting(result);
|
||||
|
||||
});
|
||||
|
||||
// Log global placeholder registration with arguments.
|
||||
UtilitiesOG.logToConsole(
|
||||
InternalFunctions.getPrefix(),
|
||||
"Registered Global MiniPlaceholder: " + miniPlaceholderPrefix + "_" + miniPlaceholderSuffix
|
||||
+ " with arguments");
|
||||
UtilitiesOG.logToConsole(InternalFunctions.getPrefix(), "Registered Global MiniPlaceholder: "
|
||||
+ miniPlaceholderPrefix + "_" + miniPlaceholderSuffix + " with arguments");
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
// Set audience placeholder without arguments.
|
||||
public PlaceholderUtils setAudiencePlaceholder(Function<Player, String> placeholder) {
|
||||
|
||||
this.placeholderRegistration =
|
||||
builder -> builder.audiencePlaceholder(miniPlaceholderSuffix, (audience, queue, ctx) -> {
|
||||
this.placeholderRegistration = builder -> builder.audiencePlaceholder(miniPlaceholderSuffix,
|
||||
(audience, queue, ctx) ->
|
||||
{
|
||||
|
||||
if (audience instanceof Player player) {
|
||||
|
||||
TextComponent result = TextUtils.expandTextWithPlaceholders(placeholder.apply(player), player);
|
||||
final TextComponent result = TextUtils.expandTextWithPlaceholders(placeholder.apply(player),
|
||||
player);
|
||||
|
||||
return Tag.inserting(result);
|
||||
|
||||
}
|
||||
|
||||
return Tag.inserting(Component.text(""));
|
||||
|
||||
});
|
||||
|
||||
// Log audience placeholder registration without arguments.
|
||||
UtilitiesOG.logToConsole(
|
||||
InternalFunctions.getPrefix(),
|
||||
"Registered Audience MiniPlaceholder: " + miniPlaceholderPrefix + "_" + miniPlaceholderSuffix
|
||||
+ " without arguments");
|
||||
UtilitiesOG.logToConsole(InternalFunctions.getPrefix(), "Registered Audience MiniPlaceholder: "
|
||||
+ miniPlaceholderPrefix + "_" + miniPlaceholderSuffix + " without arguments");
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
// Set audience placeholder with arguments.
|
||||
public PlaceholderUtils setAudiencePlaceholder(BiFunction<Player, List<String>, String> valueFunction) {
|
||||
|
||||
this.placeholderRegistration =
|
||||
builder -> builder.audiencePlaceholder(miniPlaceholderSuffix, (audience, queue, ctx) -> {
|
||||
this.placeholderRegistration = builder -> builder.audiencePlaceholder(miniPlaceholderSuffix,
|
||||
(audience, queue, ctx) ->
|
||||
{
|
||||
|
||||
if (audience instanceof Player player) {
|
||||
|
||||
List<String> args = new ArrayList<>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
while (queue.hasNext()) {
|
||||
|
||||
args.add(queue.pop().value());
|
||||
|
||||
}
|
||||
|
||||
String resultString = valueFunction.apply(player, args);
|
||||
final String resultString = valueFunction.apply(player, args);
|
||||
|
||||
TextComponent result = TextUtils.expandTextWithPlaceholders(resultString, player);
|
||||
final TextComponent result = TextUtils.expandTextWithPlaceholders(resultString, player);
|
||||
|
||||
return Tag.inserting(result);
|
||||
|
||||
}
|
||||
|
||||
return Tag.inserting(Component.text(""));
|
||||
|
||||
});
|
||||
|
||||
// Log audience placeholder registration with arguments.
|
||||
UtilitiesOG.logToConsole(
|
||||
InternalFunctions.getPrefix(),
|
||||
"Registered Audience MiniPlaceholder: " + miniPlaceholderPrefix + "_" + miniPlaceholderSuffix
|
||||
+ " with arguments");
|
||||
UtilitiesOG.logToConsole(InternalFunctions.getPrefix(), "Registered Audience MiniPlaceholder: "
|
||||
+ miniPlaceholderPrefix + "_" + miniPlaceholderSuffix + " with arguments");
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
// Set relational placeholder without arguments.
|
||||
public PlaceholderUtils setRelationalPlaceholder(BiFunction<Player, Player, String> placeholder) {
|
||||
|
||||
this.placeholderRegistration = builder ->
|
||||
builder.relationalPlaceholder(miniPlaceholderSuffix, (audience, otherAudience, queue, ctx) -> {
|
||||
this.placeholderRegistration = builder -> builder.relationalPlaceholder(miniPlaceholderSuffix,
|
||||
(audience, otherAudience, queue, ctx) ->
|
||||
{
|
||||
|
||||
if (audience instanceof Player player && otherAudience instanceof Player targetPlayer) {
|
||||
|
||||
String resultString = placeholder.apply(player, targetPlayer);
|
||||
final String resultString = placeholder.apply(player, targetPlayer);
|
||||
|
||||
TextComponent result = TextUtils.expandTextWithPlaceholders(resultString, player, targetPlayer);
|
||||
final TextComponent result = TextUtils.expandTextWithPlaceholders(resultString, player,
|
||||
targetPlayer);
|
||||
|
||||
return Tag.inserting(result);
|
||||
|
||||
}
|
||||
|
||||
return Tag.inserting(Component.text(""));
|
||||
|
||||
});
|
||||
|
||||
// Log relational placeholder registration without arguments
|
||||
UtilitiesOG.logToConsole(
|
||||
InternalFunctions.getPrefix(),
|
||||
"Registered Relational MiniPlaceholder: " + miniPlaceholderPrefix + "_" + miniPlaceholderSuffix
|
||||
+ " without arguments");
|
||||
UtilitiesOG.logToConsole(InternalFunctions.getPrefix(), "Registered Relational MiniPlaceholder: "
|
||||
+ miniPlaceholderPrefix + "_" + miniPlaceholderSuffix + " without arguments");
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
// Set relational placeholder with arguments.
|
||||
public PlaceholderUtils setRelationalPlaceholder(
|
||||
UtilitiesOG.TriFunction<Player, Player, List<String>, String> valueFunction) {
|
||||
UtilitiesOG.TriFunction<Player, Player, List<String>, String> valueFunction)
|
||||
{
|
||||
|
||||
this.placeholderRegistration = builder -> builder.relationalPlaceholder(miniPlaceholderSuffix,
|
||||
(audience, otherAudience, queue, ctx) ->
|
||||
{
|
||||
|
||||
this.placeholderRegistration = builder ->
|
||||
builder.relationalPlaceholder(miniPlaceholderSuffix, (audience, otherAudience, queue, ctx) -> {
|
||||
if (audience instanceof Player player && otherAudience instanceof Player targetPlayer) {
|
||||
|
||||
List<String> args = new ArrayList<>();
|
||||
final List<String> args = new ArrayList<>();
|
||||
while (queue.hasNext()) {
|
||||
|
||||
args.add(queue.pop().value());
|
||||
|
||||
}
|
||||
|
||||
String resultString = valueFunction.apply(player, targetPlayer, args);
|
||||
final String resultString = valueFunction.apply(player, targetPlayer, args);
|
||||
|
||||
TextComponent result = TextUtils.expandTextWithPlaceholders(resultString, player, targetPlayer);
|
||||
final TextComponent result = TextUtils.expandTextWithPlaceholders(resultString, player,
|
||||
targetPlayer);
|
||||
|
||||
return Tag.inserting(result);
|
||||
|
||||
}
|
||||
|
||||
return Tag.inserting(Component.text(""));
|
||||
|
||||
});
|
||||
|
||||
// Log relational placeholder registration with arguments.
|
||||
UtilitiesOG.logToConsole(
|
||||
InternalFunctions.getPrefix(),
|
||||
"Registered Relational MiniPlaceholder: " + miniPlaceholderPrefix + "_" + miniPlaceholderSuffix
|
||||
+ " with arguments");
|
||||
UtilitiesOG.logToConsole(InternalFunctions.getPrefix(), "Registered Relational MiniPlaceholder: "
|
||||
+ miniPlaceholderPrefix + "_" + miniPlaceholderSuffix + " with arguments");
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
// Register the MiniPlaceholder.
|
||||
public void register() {
|
||||
|
||||
ExpansionData data = expansionDataMap.computeIfAbsent(miniPlaceholderPrefix, k -> new ExpansionData(k));
|
||||
final ExpansionData data = expansionDataMap.computeIfAbsent(miniPlaceholderPrefix, ExpansionData::new);
|
||||
|
||||
data.addPlaceholderRegistration(placeholderRegistration);
|
||||
|
||||
}
|
||||
|
||||
// API for registering the MiniPlaceholder (global, audience, relational, or with args).
|
||||
public static void trueogRegisterMiniPlaceholder(
|
||||
String placeholderName, Consumer<PlaceholderUtils> placeholderConfigurator) {
|
||||
// API for registering the MiniPlaceholder (global, audience, relational, or
|
||||
// with args).
|
||||
public static void trueogRegisterMiniPlaceholder(String placeholderName,
|
||||
Consumer<PlaceholderUtils> placeholderConfigurator)
|
||||
{
|
||||
|
||||
int lastIndex = placeholderName.lastIndexOf('_');
|
||||
final int lastIndex = placeholderName.lastIndexOf('_');
|
||||
if (lastIndex == -1) {
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
"ERROR: MiniPlaceholder name must contain an underscore separating its prefix and suffix.");
|
||||
|
||||
}
|
||||
|
||||
String placeholderPrefix = placeholderName.substring(0, lastIndex);
|
||||
String placeholderSuffix = placeholderName.substring(lastIndex + 1);
|
||||
final String placeholderPrefix = StringUtils.substring(placeholderName, 0, lastIndex);
|
||||
final String placeholderSuffix = StringUtils.substring(placeholderName, lastIndex + 1);
|
||||
|
||||
PlaceholderUtils placeholderUtils = new PlaceholderUtils(placeholderPrefix, placeholderSuffix);
|
||||
final PlaceholderUtils placeholderUtils = new PlaceholderUtils(placeholderPrefix, placeholderSuffix);
|
||||
|
||||
placeholderConfigurator.accept(placeholderUtils);
|
||||
|
||||
placeholderUtils.register();
|
||||
|
||||
}
|
||||
|
||||
// Inner class to hold expansion data.
|
||||
@@ -233,6 +258,7 @@ public class PlaceholderUtils {
|
||||
public ExpansionData(String prefix) {
|
||||
|
||||
this.prefix = prefix;
|
||||
|
||||
}
|
||||
|
||||
public void addPlaceholderRegistration(Consumer<Expansion.Builder> placeholderRegistration) {
|
||||
@@ -240,6 +266,7 @@ public class PlaceholderUtils {
|
||||
this.placeholderRegistrations.add(placeholderRegistration);
|
||||
|
||||
rebuildExpansion();
|
||||
|
||||
}
|
||||
|
||||
private void rebuildExpansion() {
|
||||
@@ -247,20 +274,21 @@ public class PlaceholderUtils {
|
||||
if (registered) {
|
||||
|
||||
expansion.unregister();
|
||||
|
||||
}
|
||||
|
||||
Expansion.Builder builder = Expansion.builder(prefix);
|
||||
for (Consumer<Expansion.Builder> registration : placeholderRegistrations) {
|
||||
final Expansion.Builder builder = Expansion.builder(prefix);
|
||||
|
||||
registration.accept(builder);
|
||||
}
|
||||
placeholderRegistrations.forEach(registration -> registration.accept(builder));
|
||||
|
||||
expansion = builder.build();
|
||||
|
||||
expansion.register();
|
||||
|
||||
registered = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void unregisterAll() {
|
||||
@@ -272,9 +300,13 @@ public class PlaceholderUtils {
|
||||
data.expansion.unregister();
|
||||
|
||||
data.registered = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
expansionDataMap.clear();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,50 +2,34 @@
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package net.trueog.utilitiesog.utils;
|
||||
|
||||
import io.github.miniplaceholders.api.MiniPlaceholders;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.miniplaceholders.api.MiniPlaceholders;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.trueog.utilitiesog.misc.ColorCodeMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TextUtils {
|
||||
|
||||
// Regular expressions to match color codes starting with § or & in Strings.
|
||||
private static final Pattern LEGACY_COLOR_PATTERN = Pattern.compile("(?i)[§&][0-9A-FK-OR]");
|
||||
private static final List<String> MINIMESSAGE_TAGS = List.of(
|
||||
"<black>",
|
||||
"<dark_blue>",
|
||||
"<dark_green>",
|
||||
"<dark_aqua>",
|
||||
"<dark_red>",
|
||||
"<dark_purple>",
|
||||
"<gold>",
|
||||
"<gray>",
|
||||
"<dark_gray>",
|
||||
"<blue>",
|
||||
"<green>",
|
||||
"<aqua>",
|
||||
"<red>",
|
||||
"<light_purple>",
|
||||
"<yellow>",
|
||||
"<white>",
|
||||
"<obfuscated>",
|
||||
"<bold>",
|
||||
"<strikethrough>",
|
||||
"<underlined>",
|
||||
"<italic>",
|
||||
"<reset>",
|
||||
"<rainbow>");
|
||||
private static final List<String> MINIMESSAGE_TAGS = List.of("<black>", "<dark_blue>", "<dark_green>",
|
||||
"<dark_aqua>", "<dark_red>", "<dark_purple>", "<gold>", "<gray>", "<dark_gray>", "<blue>", "<green>",
|
||||
"<aqua>", "<red>", "<light_purple>", "<yellow>", "<white>", "<obfuscated>", "<bold>", "<strikethrough>",
|
||||
"<underlined>", "<italic>", "<reset>", "<rainbow>");
|
||||
|
||||
// Sends a formatted message to the player, expanding placeholders and color codes.
|
||||
// Sends a formatted message to the player, expanding placeholders and color
|
||||
// codes.
|
||||
public static void trueogMessage(Player player, String message) {
|
||||
|
||||
player.sendMessage(expandTextWithPlaceholders(message, player));
|
||||
|
||||
}
|
||||
|
||||
// Expand global MiniPlaceholders recursively.
|
||||
@@ -55,10 +39,11 @@ public class TextUtils {
|
||||
message = processColorCodes(message);
|
||||
|
||||
// Use global MiniPlaceholders for the resolver.
|
||||
TagResolver resolver = MiniPlaceholders.getGlobalPlaceholders();
|
||||
final TagResolver resolver = MiniPlaceholders.getGlobalPlaceholders();
|
||||
|
||||
// Recursively expand the MiniPlaceholders.
|
||||
return recursivelyExpandPlaceholders(message, resolver);
|
||||
|
||||
}
|
||||
|
||||
// Expand MiniPlaceholders with player-specific context recursively.
|
||||
@@ -68,11 +53,12 @@ public class TextUtils {
|
||||
message = processColorCodes(message);
|
||||
|
||||
// Create a resolver for global and audience-specific MiniPlaceholders.
|
||||
TagResolver resolver = TagResolver.resolver(
|
||||
MiniPlaceholders.getGlobalPlaceholders(), MiniPlaceholders.getAudiencePlaceholders(player));
|
||||
final TagResolver resolver = TagResolver.resolver(MiniPlaceholders.getGlobalPlaceholders(),
|
||||
MiniPlaceholders.getAudiencePlaceholders(player));
|
||||
|
||||
// Recursively expand MiniPlaceholders using MiniMessage.
|
||||
return recursivelyExpandPlaceholders(message, resolver);
|
||||
|
||||
}
|
||||
|
||||
// Relational placeholder expansion between two players.
|
||||
@@ -82,13 +68,13 @@ public class TextUtils {
|
||||
message = processColorCodes(message);
|
||||
|
||||
// Create a resolver for global, audience, and relational MiniPlaceholders.
|
||||
TagResolver resolver = TagResolver.resolver(
|
||||
MiniPlaceholders.getGlobalPlaceholders(),
|
||||
final TagResolver resolver = TagResolver.resolver(MiniPlaceholders.getGlobalPlaceholders(),
|
||||
MiniPlaceholders.getAudiencePlaceholders(player),
|
||||
MiniPlaceholders.getRelationalPlaceholders(player, target));
|
||||
|
||||
// Recursively expand MiniPlaceholders using MiniMessage.
|
||||
return recursivelyExpandPlaceholders(message, resolver);
|
||||
|
||||
}
|
||||
|
||||
// Recursive placeholder expansion using MiniMessage.
|
||||
@@ -97,7 +83,8 @@ public class TextUtils {
|
||||
String previousMessage;
|
||||
Component expandedMessage;
|
||||
|
||||
// Loop until no new MiniPlaceholders are found (to handle recursive expansions).
|
||||
// Loop until no new MiniPlaceholders are found (to handle recursive
|
||||
// expansions).
|
||||
do {
|
||||
|
||||
previousMessage = message;
|
||||
@@ -109,14 +96,17 @@ public class TextUtils {
|
||||
} while (!message.equals(previousMessage));
|
||||
|
||||
return (TextComponent) expandedMessage;
|
||||
|
||||
}
|
||||
|
||||
// Process color codes, converting legacy Bukkit color codes (e.g., &c) to MiniMessage-compatible codes.
|
||||
// Process color codes, converting legacy Bukkit color codes (e.g., &c) to
|
||||
// MiniMessage-compatible codes.
|
||||
public static String processColorCodes(String message) {
|
||||
|
||||
// Keeps track of the ampersand count in the loop.
|
||||
int count = 0;
|
||||
// Count the number of ampersand characters to determine how many there are for lowercase conversion.
|
||||
// Count the number of ampersand characters to determine how many there are for
|
||||
// lowercase conversion.
|
||||
for (char c : message.toCharArray()) {
|
||||
|
||||
// If the character is an ampersand, do this...
|
||||
@@ -124,30 +114,37 @@ public class TextUtils {
|
||||
|
||||
// Increase the ampersand count by 1.
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Keeps track of the positions of '&' characters in the message String.
|
||||
int[] positions = new int[count];
|
||||
final int[] positions = new int[count];
|
||||
// Keep track of the position of the metaphorical cursor in the message String.
|
||||
int index = 0;
|
||||
// Iterate through the message String to find the positions of '&' characters for lowercase conversion.
|
||||
// Iterate through the message String to find the positions of '&' characters
|
||||
// for lowercase conversion.
|
||||
for (int i = 0; i < message.length(); i++) {
|
||||
|
||||
// If the character is an ampersand, do this...
|
||||
if (message.charAt(i) == '&') {
|
||||
|
||||
// If the character directly after the ampersand is a valid uppercase Bukkit color code, do this...
|
||||
// If the character directly after the ampersand is a valid uppercase Bukkit
|
||||
// color code, do this...
|
||||
if (isUpperBukkitCode(message.charAt(i + 1))) {
|
||||
|
||||
// Replace the valid uppercase Bukkit color code with the equivalent lowercase one.
|
||||
message = replaceAtIndex(
|
||||
message, (i + 1), Character.toString(Character.toLowerCase(message.charAt(i + 1))));
|
||||
// Replace the valid uppercase Bukkit color code with the equivalent lowercase
|
||||
// one.
|
||||
message = replaceAtIndex(message, (i + 1),
|
||||
Character.toString(Character.toLowerCase(message.charAt(i + 1))));
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// Convert the newly uniform legacy Bukkit color codes into modern MiniMessage color / formatting
|
||||
// Convert the newly uniform legacy Bukkit color codes into modern MiniMessage
|
||||
// color / formatting
|
||||
// codes.
|
||||
message = replaceAtIndex(message, (i + 1), ColorCodeMap.toMiniMessage(message.charAt(i + 1)));
|
||||
|
||||
@@ -156,17 +153,21 @@ public class TextUtils {
|
||||
|
||||
} catch (NullPointerException error) {
|
||||
|
||||
// Do nothing, ampersand is intended to be in the message, since it's not a valid color code.
|
||||
// Do nothing, ampersand is intended to be in the message, since it's not a
|
||||
// valid color code.
|
||||
|
||||
}
|
||||
|
||||
// Move the metaphorical cursor forward by one.
|
||||
positions[index++] = i;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return the processed message with modern color codes.
|
||||
return message;
|
||||
|
||||
}
|
||||
|
||||
// Strips color codes and MiniMessage tags from a String.
|
||||
@@ -175,6 +176,7 @@ public class TextUtils {
|
||||
if (input == null) {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
String stripped = input;
|
||||
@@ -182,29 +184,33 @@ public class TextUtils {
|
||||
for (String tag : MINIMESSAGE_TAGS) {
|
||||
|
||||
stripped = stripped.replace(tag, "");
|
||||
|
||||
}
|
||||
|
||||
return LEGACY_COLOR_PATTERN.matcher(stripped).replaceAll("");
|
||||
|
||||
}
|
||||
|
||||
// Sends an error message to the player if they lack the required permission.
|
||||
public static void permissionsErrorMessage(Player player, String command, String permission) {
|
||||
|
||||
trueogMessage(
|
||||
player,
|
||||
trueogMessage(player,
|
||||
"&cERROR: You do not have permission to run /" + command + ". &6Required permission: &e" + permission);
|
||||
|
||||
}
|
||||
|
||||
// Logs a Component message to the console, stripping any colors.
|
||||
public static void logToConsole(String message) {
|
||||
|
||||
Bukkit.getLogger().info(stripColors(message));
|
||||
|
||||
}
|
||||
|
||||
// Detects if a Bukkit color code is uppercase (e.g., &C, &L).
|
||||
private static boolean isUpperBukkitCode(char input) {
|
||||
|
||||
return "ABCDEFKLMNOR".indexOf(Character.toUpperCase(input)) != -1;
|
||||
|
||||
}
|
||||
|
||||
// Replaces a character in a string at a given index with a new String.
|
||||
@@ -213,8 +219,11 @@ public class TextUtils {
|
||||
if (index >= 0 && index < original.length()) {
|
||||
|
||||
return original.substring(0, index) + newString + original.substring(index + 1);
|
||||
|
||||
}
|
||||
|
||||
return original;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
package net.trueog.utilitiesog;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class FastOfflinePlayerTest {
|
||||
|
||||
@Test
|
||||
void testIsOp() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetOp() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerialize() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsOnline() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetName() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetUniqueId() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPlayerProfile() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsBanned() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsWhitelisted() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetWhitelisted() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPlayer() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetFirstPlayed() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetLastPlayed() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHasPlayedBefore() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetBedSpawnLocation() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetLastLogin() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetLastSeen() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIncrementStatisticStatistic() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDecrementStatisticStatistic() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIncrementStatisticStatisticInt() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDecrementStatisticStatisticInt() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetStatisticStatisticInt() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetStatisticStatistic() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIncrementStatisticStatisticMaterial() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDecrementStatisticStatisticMaterial() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetStatisticStatisticMaterial() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIncrementStatisticStatisticMaterialInt() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDecrementStatisticStatisticMaterialInt() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetStatisticStatisticMaterialInt() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIncrementStatisticStatisticEntityType() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDecrementStatisticStatisticEntityType() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetStatisticStatisticEntityType() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIncrementStatisticStatisticEntityTypeInt() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDecrementStatisticStatisticEntityTypeInt() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetStatisticStatisticEntityTypeInt() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetLastDeathLocation() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAllowFlight() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetAllowFlight() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsFlying() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetFlying() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetFlySpeed() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetWalkSpeed() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetFlySpeed() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetWalkSpeed() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetLocation() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTeleportOfflineLocation() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTeleportOfflineLocationTeleportCause() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTeleportOfflineAsyncLocation() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTeleportOfflineAsyncLocationTeleportCause() {
|
||||
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user