Milestone towards tracking config files on git. Waiting on true-og/SubstAgent update
This commit is contained in:
1 parent
bb1846d086
commit
b45037511f
200 files changed
+17340
-9325
No files matched your search
+26
-6
@@ -1,17 +1,16 @@
|
|||||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
import org.apache.tools.ant.filters.ReplaceTokens
|
|
||||||
import org.gradle.jvm.tasks.Jar
|
|
||||||
|
|
||||||
/* ------------------------------ Plugins ------------------------------ */
|
/* ------------------------------ Plugins ------------------------------ */
|
||||||
plugins {
|
plugins {
|
||||||
id("java") // Import Java plugin.
|
id("java") // Import Java plugin.
|
||||||
id("java-library") // Import Java Library plugin.
|
id("java-library") // Import Java Library plugin.
|
||||||
id("com.diffplug.spotless") version "7.0.4" // Import Spotless plugin.
|
id("com.diffplug.spotless") version "8.1.0" // Import Spotless plugin.
|
||||||
id("com.gradleup.shadow") version "8.3.6" // Import Shadow plugin.
|
id("com.gradleup.shadow") version "8.3.9" // Import Shadow plugin.
|
||||||
id("checkstyle") // Import Checkstyle plugin.
|
id("checkstyle") // Import Checkstyle plugin.
|
||||||
eclipse // Import Eclipse plugin.
|
eclipse // Import Eclipse plugin.
|
||||||
kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin.
|
kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin.
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------- JDK / Kotlin ---------------------------- */
|
/* --------------------------- JDK / Kotlin ---------------------------- */
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
|
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
|
||||||
@@ -23,7 +22,7 @@ java {
|
|||||||
|
|
||||||
kotlin { jvmToolchain(17) }
|
kotlin { jvmToolchain(17) }
|
||||||
|
|
||||||
/* ----------------------------- // Declare bundle identifier. Metadata ------------------------------ */
|
/* ----------------------------- Metadata ------------------------------ */
|
||||||
group = "net.coreprotect"
|
group = "net.coreprotect"
|
||||||
|
|
||||||
val version = "22.4" // Declare plugin version (will be in .jar).
|
val version = "22.4" // Declare plugin version (will be in .jar).
|
||||||
@@ -54,9 +53,9 @@ repositories {
|
|||||||
|
|
||||||
/* ---------------------- Java project deps ---------------------------- */
|
/* ---------------------- Java project deps ---------------------------- */
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(platform("com.intellectualsites.bom:bom-newest:1.45"))
|
|
||||||
compileOnly("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT")
|
||||||
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT")
|
||||||
|
implementation(platform("com.intellectualsites.bom:bom-newest:1.45"))
|
||||||
implementation("com.zaxxer:HikariCP:5.0.1")
|
implementation("com.zaxxer:HikariCP:5.0.1")
|
||||||
implementation("com.github.oshi:oshi-core:6.6.5")
|
implementation("com.github.oshi:oshi-core:6.6.5")
|
||||||
}
|
}
|
||||||
@@ -94,9 +93,30 @@ tasks.withType<JavaCompile>().configureEach {
|
|||||||
options.encoding = "UTF-8" // Use UTF-8 file encoding.
|
options.encoding = "UTF-8" // Use UTF-8 file encoding.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------- Auto Formatting ------------------------ */
|
||||||
|
spotless {
|
||||||
|
java {
|
||||||
|
eclipse().configFile("config/formatter/eclipse-java-formatter.xml") // Eclipse java formatting.
|
||||||
|
leadingTabsToSpaces() // Convert leftover leading tabs to spaces.
|
||||||
|
removeUnusedImports() // Remove imports that aren't being called.
|
||||||
|
}
|
||||||
|
kotlinGradle {
|
||||||
|
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } // JetBrains Kotlin formatting.
|
||||||
|
target("build.gradle.kts", "settings.gradle.kts") // Gradle files to format.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
checkstyle {
|
checkstyle {
|
||||||
toolVersion = "10.18.1" // Declare checkstyle version to use.
|
toolVersion = "10.18.1" // Declare checkstyle version to use.
|
||||||
configFile = file("config/checkstyle/checkstyle.xml") // Point checkstyle to config file.
|
configFile = file("config/checkstyle/checkstyle.xml") // Point checkstyle to config file.
|
||||||
isIgnoreFailures = true // Don't fail the build if checkstyle does not pass.
|
isIgnoreFailures = true // Don't fail the build if checkstyle does not pass.
|
||||||
isShowViolations = true // Show the violations in any IDE with the checkstyle plugin.
|
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,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>
|
||||||
@@ -3,6 +3,12 @@ package net.coreprotect;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import net.coreprotect.command.CommandHandler;
|
import net.coreprotect.command.CommandHandler;
|
||||||
import net.coreprotect.command.TabHandler;
|
import net.coreprotect.command.TabHandler;
|
||||||
import net.coreprotect.config.Config;
|
import net.coreprotect.config.Config;
|
||||||
@@ -20,12 +26,6 @@ import net.coreprotect.thread.Scheduler;
|
|||||||
import net.coreprotect.utility.Chat;
|
import net.coreprotect.utility.Chat;
|
||||||
import net.coreprotect.utility.Teleport;
|
import net.coreprotect.utility.Teleport;
|
||||||
import net.coreprotect.utility.Util;
|
import net.coreprotect.utility.Util;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
public final class CoreProtect extends JavaPlugin {
|
public final class CoreProtect extends JavaPlugin {
|
||||||
|
|
||||||
@@ -37,10 +37,12 @@ public final class CoreProtect extends JavaPlugin {
|
|||||||
* @return This CoreProtect instance
|
* @return This CoreProtect instance
|
||||||
*/
|
*/
|
||||||
public static CoreProtect getInstance() {
|
public static CoreProtect getInstance() {
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CoreProtectAPI api = new CoreProtectAPI();
|
private final CoreProtectAPI api = new CoreProtectAPI();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the CoreProtect API
|
* Get the CoreProtect API
|
||||||
@@ -48,18 +50,23 @@ public final class CoreProtect extends JavaPlugin {
|
|||||||
* @return The CoreProtect API
|
* @return The CoreProtect API
|
||||||
*/
|
*/
|
||||||
public CoreProtectAPI getAPI() {
|
public CoreProtectAPI getAPI() {
|
||||||
|
|
||||||
return api;
|
return api;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
ConfigHandler.path = this.getDataFolder().getPath() + File.separator;
|
ConfigHandler.path = this.getDataFolder().getPath() + File.separator;
|
||||||
Language.loadPhrases();
|
Language.loadPhrases();
|
||||||
|
|
||||||
boolean start = performVersionChecks();
|
boolean start = performVersionChecks();
|
||||||
if (start) {
|
if (start) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Consumer.initialize(); // Prepare consumer (keep this here)
|
Consumer.initialize(); // Prepare consumer (keep this here)
|
||||||
new ListenerHandler(this);
|
new ListenerHandler(this);
|
||||||
getCommand("coreprotect").setExecutor(CommandHandler.getInstance());
|
getCommand("coreprotect").setExecutor(CommandHandler.getInstance());
|
||||||
@@ -69,146 +76,207 @@ public final class CoreProtect extends JavaPlugin {
|
|||||||
getCommand("co").setExecutor(CommandHandler.getInstance());
|
getCommand("co").setExecutor(CommandHandler.getInstance());
|
||||||
getCommand("co").setTabCompleter(new TabHandler());
|
getCommand("co").setTabCompleter(new TabHandler());
|
||||||
|
|
||||||
boolean exists = (new File(ConfigHandler.path)).exists();
|
final boolean exists = (new File(ConfigHandler.path)).exists();
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
|
|
||||||
new File(ConfigHandler.path).mkdir();
|
new File(ConfigHandler.path).mkdir();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start = ConfigHandler.performInitialization(true); // Perform any necessary initialization
|
start = ConfigHandler.performInitialization(true); // Perform any necessary initialization
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
} catch (Exception error) {
|
||||||
|
|
||||||
|
error.printStackTrace();
|
||||||
start = false;
|
start = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start) {
|
if (start) {
|
||||||
PluginDescriptionFile pluginDescription = this.getDescription();
|
|
||||||
Util.sendConsoleComponentStartup(
|
Util.sendConsoleComponentStartup(Bukkit.getServer().getConsoleSender(),
|
||||||
Bukkit.getServer().getConsoleSender(),
|
|
||||||
Phrase.build(Phrase.ENABLE_SUCCESS, ConfigHandler.EDITION_NAME));
|
Phrase.build(Phrase.ENABLE_SUCCESS, ConfigHandler.EDITION_NAME));
|
||||||
if (Config.getGlobal().MYSQL) {
|
if (Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.USING_MYSQL));
|
Chat.console(Phrase.build(Phrase.USING_MYSQL));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.USING_SQLITE));
|
Chat.console(Phrase.build(Phrase.USING_SQLITE));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.console("--------------------");
|
Chat.console("--------------------");
|
||||||
Chat.console(Phrase.build(Phrase.ENJOY_COREPROTECT, pluginDescription.getName()));
|
Chat.console(Phrase.build(Phrase.ENJOY_COREPROTECT, getPluginMeta().getName()));
|
||||||
Chat.console(Phrase.build(Phrase.LINK_DISCORD, "www.coreprotect.net/discord/"));
|
Chat.console(Phrase.build(Phrase.LINK_DISCORD, "www.coreprotect.net/discord/"));
|
||||||
Chat.console("--------------------");
|
Chat.console("--------------------");
|
||||||
|
|
||||||
Scheduler.scheduleSyncDelayedTask(
|
Scheduler.scheduleSyncDelayedTask(this, () -> {
|
||||||
this,
|
|
||||||
() -> {
|
|
||||||
try {
|
|
||||||
Thread networkHandler = new Thread(new NetworkHandler(true, true));
|
|
||||||
networkHandler.start();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
0);
|
|
||||||
|
|
||||||
Thread cacheCleanUpThread = new Thread(new CacheHandler());
|
try {
|
||||||
|
|
||||||
|
final Thread networkHandler = new Thread(new NetworkHandler(true, true));
|
||||||
|
networkHandler.start();
|
||||||
|
|
||||||
|
} catch (Exception error) {
|
||||||
|
|
||||||
|
error.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
final Thread cacheCleanUpThread = new Thread(new CacheHandler());
|
||||||
cacheCleanUpThread.start();
|
cacheCleanUpThread.start();
|
||||||
|
|
||||||
Consumer.startConsumer();
|
Consumer.startConsumer();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.ENABLE_FAILED, ConfigHandler.EDITION_NAME));
|
Chat.console(Phrase.build(Phrase.ENABLE_FAILED, ConfigHandler.EDITION_NAME));
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
safeShutdown(this);
|
safeShutdown(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean performVersionChecks() {
|
private static boolean performVersionChecks() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String[] bukkitVersion = Bukkit.getServer().getBukkitVersion().split("[-.]");
|
|
||||||
|
final String[] bukkitVersion = Bukkit.getServer().getBukkitVersion().split("[-.]");
|
||||||
if (Util.newVersion(bukkitVersion[0] + "." + bukkitVersion[1], ConfigHandler.MINECRAFT_VERSION)) {
|
if (Util.newVersion(bukkitVersion[0] + "." + bukkitVersion[1], ConfigHandler.MINECRAFT_VERSION)) {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Minecraft", ConfigHandler.MINECRAFT_VERSION));
|
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Minecraft", ConfigHandler.MINECRAFT_VERSION));
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Util.newVersion(ConfigHandler.LATEST_VERSION, bukkitVersion[0] + "." + bukkitVersion[1])
|
if (Util.newVersion(ConfigHandler.LATEST_VERSION, bukkitVersion[0] + "." + bukkitVersion[1])
|
||||||
&& Util.isBranch("master")) {
|
&& Util.isBranch("master"))
|
||||||
Chat.console(Phrase.build(
|
{
|
||||||
Phrase.VERSION_INCOMPATIBLE, "Minecraft", bukkitVersion[0] + "." + bukkitVersion[1]));
|
|
||||||
|
Chat.console(Phrase.build(Phrase.VERSION_INCOMPATIBLE, "Minecraft",
|
||||||
|
bukkitVersion[0] + "." + bukkitVersion[1]));
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
String[] javaVersion = (System.getProperty("java.version").replaceAll("[^0-9.]", "") + ".0").split("\\.");
|
|
||||||
|
final String[] javaVersion = (System.getProperty("java.version").replaceAll("[^0-9.]", "") + ".0")
|
||||||
|
.split("\\.");
|
||||||
if (Util.newVersion(javaVersion[0] + "." + javaVersion[1], ConfigHandler.JAVA_VERSION)) {
|
if (Util.newVersion(javaVersion[0] + "." + javaVersion[1], ConfigHandler.JAVA_VERSION)) {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Java", ConfigHandler.JAVA_VERSION));
|
Chat.console(Phrase.build(Phrase.VERSION_REQUIRED, "Java", ConfigHandler.JAVA_VERSION));
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.SERVER_VERSION = Integer.parseInt(bukkitVersion[1]);
|
ConfigHandler.SERVER_VERSION = Integer.parseInt(bukkitVersion[1]);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
} catch (Exception error) {
|
||||||
|
|
||||||
|
error.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void safeShutdown(CoreProtect plugin) {
|
private static void safeShutdown(CoreProtect plugin) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
/* if server is stopping, log disconnections of online players */
|
/* if server is stopping, log disconnections of online players */
|
||||||
if (ConfigHandler.serverRunning && PaperAdapter.ADAPTER.isStopping(plugin.getServer())) {
|
if (ConfigHandler.serverRunning && PaperAdapter.ADAPTER.isStopping(plugin.getServer())) {
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
|
||||||
PlayerQuitListener.queuePlayerQuit(player);
|
plugin.getServer().getOnlinePlayers().forEach(PlayerQuitListener::queuePlayerQuit);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConfigHandler.isFolia) {
|
if (!ConfigHandler.isFolia) {
|
||||||
Iterator<Entry<Location, BlockData>> iterator =
|
|
||||||
Teleport.revertBlocks.entrySet().iterator();
|
final Iterator<Entry<Location, BlockData>> iterator = Teleport.revertBlocks.entrySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Entry<Location, BlockData> entry = iterator.next();
|
|
||||||
|
final Entry<Location, BlockData> entry = iterator.next();
|
||||||
entry.getKey().getBlock().setBlockData(entry.getValue());
|
entry.getKey().getBlock().setBlockData(entry.getValue());
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.serverRunning = false;
|
ConfigHandler.serverRunning = false;
|
||||||
long shutdownTime = System.currentTimeMillis();
|
final long shutdownTime = System.currentTimeMillis();
|
||||||
long alertTime = shutdownTime + (10 * 1000);
|
long alertTime = shutdownTime + (10 * 1000);
|
||||||
if (ConfigHandler.converterRunning) {
|
if (ConfigHandler.converterRunning) {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.FINISHING_CONVERSION));
|
Chat.console(Phrase.build(Phrase.FINISHING_CONVERSION));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.FINISHING_LOGGING));
|
Chat.console(Phrase.build(Phrase.FINISHING_LOGGING));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.migrationRunning) {
|
if (ConfigHandler.migrationRunning) {
|
||||||
|
|
||||||
ConfigHandler.purgeRunning = false;
|
ConfigHandler.purgeRunning = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((Consumer.isRunning() || ConfigHandler.converterRunning) && !ConfigHandler.purgeRunning) {
|
while ((Consumer.isRunning() || ConfigHandler.converterRunning) && !ConfigHandler.purgeRunning) {
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
|
final long time = System.currentTimeMillis();
|
||||||
if (time >= alertTime) {
|
if (time >= alertTime) {
|
||||||
|
|
||||||
if (!ConfigHandler.converterRunning) {
|
if (!ConfigHandler.converterRunning) {
|
||||||
int consumerId = (Consumer.currentConsumer == 1) ? 1 : 0;
|
|
||||||
int consumerCount = Consumer.getConsumerSize(consumerId) + Process.getCurrentConsumerSize();
|
final int consumerId = (Consumer.currentConsumer == 1) ? 1 : 0;
|
||||||
Chat.console(Phrase.build(Phrase.LOGGING_ITEMS, String.format("%,d", consumerCount)));
|
final int consumerCount = Consumer.getConsumerSize(consumerId)
|
||||||
|
+ Process.getCurrentConsumerSize();
|
||||||
|
Chat.console(Phrase.build(Phrase.LOGGING_ITEMS, "%,d".formatted(consumerCount)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
alertTime = alertTime + (30 * 1000);
|
alertTime = alertTime + (30 * 1000);
|
||||||
|
|
||||||
} else if (!ConfigHandler.databaseReachable && (time - shutdownTime) >= (5 * 60 * 1000)) {
|
} else if (!ConfigHandler.databaseReachable && (time - shutdownTime) >= (5 * 60 * 1000)) {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.DATABASE_UNREACHABLE));
|
Chat.console(Phrase.build(Phrase.DATABASE_UNREACHABLE));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} else if ((time - shutdownTime) >= (15 * 60 * 1000)) {
|
} else if ((time - shutdownTime) >= (15 * 60 * 1000)) {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.LOGGING_TIME_LIMIT));
|
Chat.console(Phrase.build(Phrase.LOGGING_TIME_LIMIT));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.performDisable();
|
ConfigHandler.performDisable();
|
||||||
Chat.console(Phrase.build(
|
Chat.console(Phrase.build(Phrase.DISABLE_SUCCESS, "CoreProtect v" + plugin.getPluginMeta().getVersion()));
|
||||||
Phrase.DISABLE_SUCCESS,
|
|
||||||
"CoreProtect v" + plugin.getDescription().getVersion()));
|
} catch (Exception error) {
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
error.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -14,11 +14,15 @@ import org.bukkit.block.Block;
|
|||||||
public class BlockAPI {
|
public class BlockAPI {
|
||||||
|
|
||||||
public static List<String[]> performLookup(Block block, int offset) {
|
public static List<String[]> performLookup(Block block, int offset) {
|
||||||
|
|
||||||
List<String[]> result = new ArrayList<>();
|
List<String[]> result = new ArrayList<>();
|
||||||
|
|
||||||
try (Connection connection = Database.getConnection(false, 1000)) {
|
try (Connection connection = Database.getConnection(false, 1000)) {
|
||||||
|
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = block.getX();
|
int x = block.getX();
|
||||||
@@ -28,11 +32,15 @@ public class BlockAPI {
|
|||||||
int worldId = Util.getWorldId(block.getWorld().getName());
|
int worldId = Util.getWorldId(block.getWorld().getName());
|
||||||
int checkTime = 0;
|
int checkTime = 0;
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
|
|
||||||
checkTime = time - offset;
|
checkTime = time - offset;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
@@ -42,6 +50,7 @@ public class BlockAPI {
|
|||||||
ResultSet results = statement.executeQuery(query);
|
ResultSet results = statement.executeQuery(query);
|
||||||
|
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
String resultTime = results.getString("time");
|
String resultTime = results.getString("time");
|
||||||
int resultUserId = results.getInt("user");
|
int resultUserId = results.getInt("user");
|
||||||
String resultAction = results.getString("action");
|
String resultAction = results.getString("action");
|
||||||
@@ -50,33 +59,33 @@ public class BlockAPI {
|
|||||||
byte[] resultBlockData = results.getBytes("blockdata");
|
byte[] resultBlockData = results.getBytes("blockdata");
|
||||||
String resultRolledBack = results.getString("rolled_back");
|
String resultRolledBack = results.getString("rolled_back");
|
||||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||||
|
|
||||||
UserStatement.loadName(connection, resultUserId);
|
UserStatement.loadName(connection, resultUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||||
String blockData = Util.byteDataToString(resultBlockData, resultType);
|
String blockData = Util.byteDataToString(resultBlockData, resultType);
|
||||||
|
|
||||||
String[] lookupData = new String[] {
|
String[] lookupData = new String[] { resultTime, resultUser, String.valueOf(x), String.valueOf(y),
|
||||||
resultTime,
|
String.valueOf(z), String.valueOf(resultType), resultData, resultAction, resultRolledBack,
|
||||||
resultUser,
|
String.valueOf(worldId), blockData };
|
||||||
String.valueOf(x),
|
|
||||||
String.valueOf(y),
|
|
||||||
String.valueOf(z),
|
|
||||||
String.valueOf(resultType),
|
|
||||||
resultData,
|
|
||||||
resultAction,
|
|
||||||
resultRolledBack,
|
|
||||||
String.valueOf(worldId),
|
|
||||||
blockData
|
|
||||||
};
|
|
||||||
String[] lineData = Util.toStringArray(lookupData);
|
String[] lineData = Util.toStringArray(lookupData);
|
||||||
result.add(lineData);
|
result.add(lineData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.close();
|
results.close();
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,27 +18,39 @@ import org.bukkit.block.BlockState;
|
|||||||
public class QueueLookup extends Queue {
|
public class QueueLookup extends Queue {
|
||||||
|
|
||||||
private QueueLookup() {
|
private QueueLookup() {
|
||||||
|
|
||||||
throw new IllegalStateException("API class");
|
throw new IllegalStateException("API class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String[]> performLookup(Block block) {
|
public static List<String[]> performLookup(Block block) {
|
||||||
|
|
||||||
List<String[]> result = new ArrayList<>();
|
List<String[]> result = new ArrayList<>();
|
||||||
if (!Config.getGlobal().API_ENABLED) {
|
if (!Config.getGlobal().API_ENABLED) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
int consumerCount = 0;
|
int consumerCount = 0;
|
||||||
int currentConsumerSize = Process.getCurrentConsumerSize();
|
int currentConsumerSize = Process.getCurrentConsumerSize();
|
||||||
if (currentConsumerSize == 0) {
|
if (currentConsumerSize == 0) {
|
||||||
|
|
||||||
consumerCount = Consumer.getConsumerSize(0) + Consumer.getConsumerSize(1);
|
consumerCount = Consumer.getConsumerSize(0) + Consumer.getConsumerSize(1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int consumerId = (Consumer.currentConsumer == 1) ? 1 : 0;
|
int consumerId = (Consumer.currentConsumer == 1) ? 1 : 0;
|
||||||
consumerCount = Consumer.getConsumerSize(consumerId) + currentConsumerSize;
|
consumerCount = Consumer.getConsumerSize(consumerId) + currentConsumerSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (consumerCount == 0) {
|
if (consumerCount == 0) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
@@ -49,19 +61,22 @@ public class QueueLookup extends Queue {
|
|||||||
Location oldLocation = block.getLocation();
|
Location oldLocation = block.getLocation();
|
||||||
ListIterator<Object[]> iterator = consumerData.listIterator();
|
ListIterator<Object[]> iterator = consumerData.listIterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
|
||||||
Object[] data = iterator.next();
|
Object[] data = iterator.next();
|
||||||
int id = (int) data[0];
|
int id = (int) data[0];
|
||||||
int action = (int) data[1];
|
int action = (int) data[1];
|
||||||
if (action != Process.BLOCK_BREAK && action != Process.BLOCK_PLACE) {
|
if (action != Process.BLOCK_BREAK && action != Process.BLOCK_PLACE) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] userData = users.get(id);
|
String[] userData = users.get(id);
|
||||||
Object objectData = consumerObject.get(id);
|
Object objectData = consumerObject.get(id);
|
||||||
if (userData != null
|
if (userData != null && objectData != null && (objectData instanceof BlockState)
|
||||||
&& objectData != null
|
&& ((BlockState) objectData).getLocation().equals(oldLocation))
|
||||||
&& (objectData instanceof BlockState)
|
{
|
||||||
&& ((BlockState) objectData).getLocation().equals(oldLocation)) {
|
|
||||||
Material blockType = (Material) data[2];
|
Material blockType = (Material) data[2];
|
||||||
int legacyData = (int) data[3];
|
int legacyData = (int) data[3];
|
||||||
String blockData = (String) data[7];
|
String blockData = (String) data[7];
|
||||||
@@ -72,29 +87,27 @@ public class QueueLookup extends Queue {
|
|||||||
int resultType = Util.getBlockId(blockType);
|
int resultType = Util.getBlockId(blockType);
|
||||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||||
|
|
||||||
String[] lookupData = new String[] {
|
String[] lookupData = new String[] { String.valueOf(time), user,
|
||||||
String.valueOf(time),
|
String.valueOf(location.getBlockX()), String.valueOf(location.getBlockY()),
|
||||||
user,
|
String.valueOf(location.getBlockZ()), String.valueOf(resultType),
|
||||||
String.valueOf(location.getBlockX()),
|
String.valueOf(legacyData), String.valueOf(action), "0", String.valueOf(wid), blockData };
|
||||||
String.valueOf(location.getBlockY()),
|
|
||||||
String.valueOf(location.getBlockZ()),
|
|
||||||
String.valueOf(resultType),
|
|
||||||
String.valueOf(legacyData),
|
|
||||||
String.valueOf(action),
|
|
||||||
"0",
|
|
||||||
String.valueOf(wid),
|
|
||||||
blockData
|
|
||||||
};
|
|
||||||
String[] lineData = Util.toStringArray(lookupData);
|
String[] lineData = Util.toStringArray(lookupData);
|
||||||
result.add(lineData);
|
result.add(lineData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.reverse(result);
|
Collections.reverse(result);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,37 +16,52 @@ public class SessionLookup {
|
|||||||
public static final int ID = 0;
|
public static final int ID = 0;
|
||||||
|
|
||||||
private SessionLookup() {
|
private SessionLookup() {
|
||||||
|
|
||||||
throw new IllegalStateException("API class");
|
throw new IllegalStateException("API class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String[]> performLookup(String user, int offset) {
|
public static List<String[]> performLookup(String user, int offset) {
|
||||||
|
|
||||||
List<String[]> result = new ArrayList<>();
|
List<String[]> result = new ArrayList<>();
|
||||||
if (!Config.getGlobal().API_ENABLED) {
|
if (!Config.getGlobal().API_ENABLED) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Connection connection = Database.getConnection(false, 1000)) {
|
try (Connection connection = Database.getConnection(false, 1000)) {
|
||||||
|
|
||||||
if (connection == null || user == null) {
|
if (connection == null || user == null) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String type = String.valueOf(ID);
|
String type = String.valueOf(ID);
|
||||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||||
int checkTime = 0;
|
int checkTime = 0;
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
|
|
||||||
checkTime = time - offset;
|
checkTime = time - offset;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT)) == null) {
|
if (ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT)) == null) {
|
||||||
|
|
||||||
UserStatement.loadId(connection, user, null);
|
UserStatement.loadId(connection, user, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||||
|
|
||||||
try (Statement statement = connection.createStatement()) {
|
try (Statement statement = connection.createStatement()) {
|
||||||
|
|
||||||
String query = "SELECT time,user,wid,x,y,z,action FROM " + ConfigHandler.prefix
|
String query = "SELECT time,user,wid,x,y,z,action FROM " + ConfigHandler.prefix
|
||||||
+ "session WHERE user = '" + userId + "' AND time > '" + checkTime + "' ORDER BY rowid DESC";
|
+ "session WHERE user = '" + userId + "' AND time > '" + checkTime + "' ORDER BY rowid DESC";
|
||||||
ResultSet results = statement.executeQuery(query);
|
ResultSet results = statement.executeQuery(query);
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
String resultTime = results.getString("time");
|
String resultTime = results.getString("time");
|
||||||
int resultUserId = results.getInt("user");
|
int resultUserId = results.getInt("user");
|
||||||
String resultWorldId = results.getString("wid");
|
String resultWorldId = results.getString("wid");
|
||||||
@@ -56,21 +71,31 @@ public class SessionLookup {
|
|||||||
String resultAction = results.getString("action");
|
String resultAction = results.getString("action");
|
||||||
|
|
||||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||||
|
|
||||||
UserStatement.loadName(connection, resultUserId);
|
UserStatement.loadName(connection, resultUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||||
|
|
||||||
String[] lookupData = new String[] {
|
String[] lookupData = new String[] { resultTime, resultUser, resultX, resultY, resultZ,
|
||||||
resultTime, resultUser, resultX, resultY, resultZ, resultWorldId, type, resultAction
|
resultWorldId, type, resultAction };
|
||||||
};
|
|
||||||
result.add(lookupData);
|
result.add(lookupData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.close();
|
results.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,9 @@ public class BukkitAdapter implements BukkitInterface {
|
|||||||
public static final int BUKKIT_V1_20 = 20;
|
public static final int BUKKIT_V1_20 = 20;
|
||||||
|
|
||||||
public static void loadAdapter() {
|
public static void loadAdapter() {
|
||||||
|
|
||||||
switch (ConfigHandler.SERVER_VERSION) {
|
switch (ConfigHandler.SERVER_VERSION) {
|
||||||
|
|
||||||
case BUKKIT_V1_13:
|
case BUKKIT_V1_13:
|
||||||
case BUKKIT_V1_14:
|
case BUKKIT_V1_14:
|
||||||
case BUKKIT_V1_15:
|
case BUKKIT_V1_15:
|
||||||
@@ -62,54 +64,69 @@ public class BukkitAdapter implements BukkitInterface {
|
|||||||
default:
|
default:
|
||||||
BukkitAdapter.ADAPTER = new Bukkit_v1_19();
|
BukkitAdapter.ADAPTER = new Bukkit_v1_19();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String parseLegacyName(String name) {
|
public String parseLegacyName(String name) {
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLegacyBlockId(Material material) {
|
public int getLegacyBlockId(Material material) {
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getEntityMeta(LivingEntity entity, List<Object> info) {
|
public boolean getEntityMeta(LivingEntity entity, List<Object> info) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setEntityMeta(Entity entity, Object value, int count) {
|
public boolean setEntityMeta(Entity entity, Object value, int count) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getItemMeta(
|
public boolean getItemMeta(ItemMeta itemMeta, List<Map<String, Object>> list,
|
||||||
ItemMeta itemMeta, List<Map<String, Object>> list, List<List<Map<String, Object>>> metadata, int slot) {
|
List<List<Map<String, Object>>> metadata, int slot)
|
||||||
|
{
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setItemMeta(Material rowType, ItemStack itemstack, List<Map<String, Object>> map) {
|
public boolean setItemMeta(Material rowType, ItemStack itemstack, List<Map<String, Object>> map) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAttached(Block block, Block scanBlock, BlockData blockData, int scanMin) {
|
public boolean isAttached(Block block, Block scanBlock, BlockData blockData, int scanMin) {
|
||||||
|
|
||||||
if (blockData instanceof Directional && blockData instanceof FaceAttachable) {
|
if (blockData instanceof Directional && blockData instanceof FaceAttachable) {
|
||||||
|
|
||||||
Directional directional = (Directional) blockData;
|
Directional directional = (Directional) blockData;
|
||||||
FaceAttachable faceAttachable = (FaceAttachable) blockData;
|
FaceAttachable faceAttachable = (FaceAttachable) blockData;
|
||||||
|
|
||||||
boolean scanButton = false;
|
boolean scanButton = false;
|
||||||
switch (faceAttachable.getAttachedFace()) {
|
switch (faceAttachable.getAttachedFace()) {
|
||||||
|
|
||||||
case WALL:
|
case WALL:
|
||||||
scanButton = (scanMin < 5
|
scanButton = (scanMin < 5 && scanBlock.getRelative(directional.getFacing().getOppositeFace())
|
||||||
&& scanBlock
|
.getLocation().equals(block.getLocation()));
|
||||||
.getRelative(directional.getFacing().getOppositeFace())
|
|
||||||
.getLocation()
|
|
||||||
.equals(block.getLocation()));
|
|
||||||
break;
|
break;
|
||||||
case FLOOR:
|
case FLOOR:
|
||||||
scanButton = (scanMin == 5);
|
scanButton = (scanMin == 5);
|
||||||
@@ -119,95 +136,132 @@ public class BukkitAdapter implements BukkitInterface {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return scanButton;
|
return scanButton;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; // unvalidated attachments default to true
|
return true; // unvalidated attachments default to true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMinHeight(World world) {
|
public int getMinHeight(World world) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Material getBucketContents(Material material) {
|
public Material getBucketContents(Material material) {
|
||||||
|
|
||||||
return Material.AIR;
|
return Material.AIR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemFrame(Material material) {
|
public boolean isItemFrame(Material material) {
|
||||||
|
|
||||||
return (material == Material.ITEM_FRAME);
|
return (material == Material.ITEM_FRAME);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Material getFrameType(Entity entity) {
|
public Material getFrameType(Entity entity) {
|
||||||
|
|
||||||
return Material.ITEM_FRAME;
|
return Material.ITEM_FRAME;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Material getFrameType(EntityType type) {
|
public Material getFrameType(EntityType type) {
|
||||||
|
|
||||||
return type == EntityType.ITEM_FRAME ? Material.ITEM_FRAME : null;
|
return type == EntityType.ITEM_FRAME ? Material.ITEM_FRAME : null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getFrameClass(Material material) {
|
public Class<?> getFrameClass(Material material) {
|
||||||
|
|
||||||
return ItemFrame.class;
|
return ItemFrame.class;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGlowing(Sign sign, boolean isFront) {
|
public boolean isGlowing(Sign sign, boolean isFront) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWaxed(Sign sign) {
|
public boolean isWaxed(Sign sign) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvisible(Material material) {
|
public boolean isInvisible(Material material) {
|
||||||
|
|
||||||
return Util.isAir(material);
|
return Util.isAir(material);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack adjustIngredient(MerchantRecipe recipe, ItemStack itemStack) {
|
public ItemStack adjustIngredient(MerchantRecipe recipe, ItemStack itemStack) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGlowing(Sign sign, boolean isFront, boolean isGlowing) {
|
public void setGlowing(Sign sign, boolean isFront, boolean isGlowing) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setColor(Sign sign, boolean isFront, int color) {
|
public void setColor(Sign sign, boolean isFront, int color) {
|
||||||
|
|
||||||
if (!isFront) {
|
if (!isFront) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sign.setColor(DyeColor.getByColor(Color.fromRGB(color)));
|
sign.setColor(DyeColor.getByColor(Color.fromRGB(color)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWaxed(Sign sign, boolean isWaxed) {
|
public void setWaxed(Sign sign, boolean isWaxed) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColor(Sign sign, boolean isFront) {
|
public int getColor(Sign sign, boolean isFront) {
|
||||||
|
|
||||||
if (isFront) {
|
if (isFront) {
|
||||||
|
|
||||||
return sign.getColor().getColor().asRGB();
|
return sign.getColor().getColor().asRGB();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Material getPlantSeeds(Material material) {
|
public Material getPlantSeeds(Material material) {
|
||||||
|
|
||||||
switch (material) {
|
switch (material) {
|
||||||
|
|
||||||
case WHEAT:
|
case WHEAT:
|
||||||
material = Material.WHEAT_SEEDS;
|
material = Material.WHEAT_SEEDS;
|
||||||
break;
|
break;
|
||||||
@@ -221,99 +275,143 @@ public class BukkitAdapter implements BukkitInterface {
|
|||||||
material = Material.BEETROOT_SEEDS;
|
material = Material.BEETROOT_SEEDS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return material;
|
return material;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDecoratedPot(Material material) {
|
public boolean isDecoratedPot(Material material) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuspiciousBlock(Material material) {
|
public boolean isSuspiciousBlock(Material material) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSign(Material material) {
|
public boolean isSign(Material material) {
|
||||||
|
|
||||||
return Tag.SIGNS.isTagged(material);
|
return Tag.SIGNS.isTagged(material);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChiseledBookshelf(Material material) {
|
public boolean isChiseledBookshelf(Material material) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBookshelfBook(Material material) {
|
public boolean isBookshelfBook(Material material) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getChiseledBookshelfBook(BlockState blockState, PlayerInteractEvent event) {
|
public ItemStack getChiseledBookshelfBook(BlockState blockState, PlayerInteractEvent event) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLine(Sign sign, int line) {
|
public String getLine(Sign sign, int line) {
|
||||||
|
|
||||||
if (line < 4) {
|
if (line < 4) {
|
||||||
|
|
||||||
return sign.getLine(line);
|
return sign.getLine(line);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLine(Sign sign, int line, String string) {
|
public void setLine(Sign sign, int line, String string) {
|
||||||
|
|
||||||
if (string == null) {
|
if (string == null) {
|
||||||
|
|
||||||
string = "";
|
string = "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line < 4) {
|
if (line < 4) {
|
||||||
|
|
||||||
sign.setLine(line, string);
|
sign.setLine(line, string);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSignFront(SignChangeEvent event) {
|
public boolean isSignFront(SignChangeEvent event) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getArrowMeta(Arrow arrow, ItemStack itemStack) {
|
public ItemStack getArrowMeta(Arrow arrow, ItemStack itemStack) {
|
||||||
|
|
||||||
PotionData data = arrow.getBasePotionData();
|
PotionData data = arrow.getBasePotionData();
|
||||||
if (data.getType() != PotionType.valueOf("UNCRAFTABLE")) {
|
if (data.getType() != PotionType.valueOf("UNCRAFTABLE")) {
|
||||||
|
|
||||||
itemStack = new ItemStack(Material.TIPPED_ARROW);
|
itemStack = new ItemStack(Material.TIPPED_ARROW);
|
||||||
PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
|
PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
|
||||||
meta.setBasePotionData(data);
|
meta.setBasePotionData(data);
|
||||||
for (PotionEffect effect : arrow.getCustomEffects()) {
|
for (PotionEffect effect : arrow.getCustomEffects()) {
|
||||||
|
|
||||||
meta.addCustomEffect(effect, false);
|
meta.addCustomEffect(effect, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemStack.setItemMeta(meta);
|
itemStack.setItemMeta(meta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return itemStack;
|
return itemStack;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityType getEntityType(Material material) {
|
public EntityType getEntityType(Material material) {
|
||||||
|
|
||||||
switch (material) {
|
switch (material) {
|
||||||
|
|
||||||
case END_CRYSTAL:
|
case END_CRYSTAL:
|
||||||
return EntityType.valueOf("ENDER_CRYSTAL");
|
return EntityType.valueOf("ENDER_CRYSTAL");
|
||||||
default:
|
default:
|
||||||
return EntityType.UNKNOWN;
|
return EntityType.UNKNOWN;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getRegistryKey(Object value) {
|
public Object getRegistryKey(Object value) {
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getRegistryValue(String key, Object tClass) {
|
public Object getRegistryValue(String key, Object tClass) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,8 +36,8 @@ public interface BukkitInterface {
|
|||||||
|
|
||||||
public boolean setEntityMeta(Entity entity, Object value, int count);
|
public boolean setEntityMeta(Entity entity, Object value, int count);
|
||||||
|
|
||||||
public boolean getItemMeta(
|
public boolean getItemMeta(ItemMeta itemMeta, List<Map<String, Object>> list,
|
||||||
ItemMeta itemMeta, List<Map<String, Object>> list, List<List<Map<String, Object>>> metadata, int slot);
|
List<List<Map<String, Object>>> metadata, int slot);
|
||||||
|
|
||||||
public boolean setItemMeta(Material rowType, ItemStack itemstack, List<Map<String, Object>> map);
|
public boolean setItemMeta(Material rowType, ItemStack itemstack, List<Map<String, Object>> map);
|
||||||
|
|
||||||
@@ -90,4 +90,5 @@ public interface BukkitInterface {
|
|||||||
public Object getRegistryKey(Object value);
|
public Object getRegistryKey(Object value);
|
||||||
|
|
||||||
public Object getRegistryValue(String key, Object tClass);
|
public Object getRegistryValue(String key, Object tClass);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,317 +28,179 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
public class Bukkit_v1_17 extends BukkitAdapter implements BukkitInterface {
|
public class Bukkit_v1_17 extends BukkitAdapter implements BukkitInterface {
|
||||||
|
|
||||||
public Bukkit_v1_17() {
|
public Bukkit_v1_17() {
|
||||||
BlockGroup.TRACK_ANY = new HashSet<>(Arrays.asList(
|
|
||||||
Material.PISTON_HEAD,
|
BlockGroup.TRACK_ANY = new HashSet<>(Arrays.asList(Material.PISTON_HEAD, Material.LEVER, Material.BELL,
|
||||||
Material.LEVER,
|
Material.SMALL_AMETHYST_BUD, Material.MEDIUM_AMETHYST_BUD, Material.LARGE_AMETHYST_BUD,
|
||||||
Material.BELL,
|
Material.AMETHYST_CLUSTER, Material.GLOW_LICHEN));
|
||||||
Material.SMALL_AMETHYST_BUD,
|
BlockGroup.TRACK_TOP = new HashSet<>(Arrays.asList(Material.TORCH, Material.REDSTONE_TORCH, Material.BAMBOO,
|
||||||
Material.MEDIUM_AMETHYST_BUD,
|
Material.BAMBOO_SAPLING, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE,
|
||||||
Material.LARGE_AMETHYST_BUD,
|
Material.SWEET_BERRY_BUSH, Material.SCAFFOLDING, Material.OAK_SAPLING, Material.SPRUCE_SAPLING,
|
||||||
Material.AMETHYST_CLUSTER,
|
Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING,
|
||||||
Material.GLOW_LICHEN));
|
Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH, Material.DANDELION,
|
||||||
BlockGroup.TRACK_TOP = new HashSet<>(Arrays.asList(
|
Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP,
|
||||||
Material.TORCH,
|
Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY,
|
||||||
Material.REDSTONE_TORCH,
|
Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.REDSTONE_WIRE, Material.WHEAT,
|
||||||
Material.BAMBOO,
|
Material.ACACIA_SIGN, Material.BIRCH_SIGN, Material.DARK_OAK_SIGN, Material.JUNGLE_SIGN,
|
||||||
Material.BAMBOO_SAPLING,
|
Material.OAK_SIGN, Material.SPRUCE_SIGN, Material.WHITE_BANNER, Material.ORANGE_BANNER,
|
||||||
Material.CORNFLOWER,
|
Material.MAGENTA_BANNER, Material.LIGHT_BLUE_BANNER, Material.YELLOW_BANNER, Material.LIME_BANNER,
|
||||||
Material.LILY_OF_THE_VALLEY,
|
Material.PINK_BANNER, Material.GRAY_BANNER, Material.LIGHT_GRAY_BANNER, Material.CYAN_BANNER,
|
||||||
Material.WITHER_ROSE,
|
Material.PURPLE_BANNER, Material.BLUE_BANNER, Material.BROWN_BANNER, Material.GREEN_BANNER,
|
||||||
Material.SWEET_BERRY_BUSH,
|
Material.RED_BANNER, Material.BLACK_BANNER, Material.RAIL, Material.IRON_DOOR, Material.SNOW,
|
||||||
Material.SCAFFOLDING,
|
Material.CACTUS, Material.SUGAR_CANE, Material.REPEATER, Material.PUMPKIN_STEM, Material.MELON_STEM,
|
||||||
Material.OAK_SAPLING,
|
Material.CARROT, Material.POTATO, Material.COMPARATOR, Material.ACTIVATOR_RAIL, Material.SUNFLOWER,
|
||||||
Material.SPRUCE_SAPLING,
|
Material.LILAC, Material.TALL_GRASS, Material.LARGE_FERN, Material.ROSE_BUSH, Material.PEONY,
|
||||||
Material.BIRCH_SAPLING,
|
Material.NETHER_WART, Material.CHORUS_PLANT, Material.CHORUS_FLOWER, Material.KELP, Material.SOUL_TORCH,
|
||||||
Material.JUNGLE_SAPLING,
|
Material.TWISTING_VINES, Material.CRIMSON_FUNGUS, Material.WARPED_FUNGUS, Material.CRIMSON_ROOTS,
|
||||||
Material.ACACIA_SAPLING,
|
Material.WARPED_ROOTS, Material.NETHER_SPROUTS, Material.CRIMSON_SIGN, Material.WARPED_SIGN,
|
||||||
Material.DARK_OAK_SAPLING,
|
Material.AZALEA, Material.FLOWERING_AZALEA, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF));
|
||||||
Material.POWERED_RAIL,
|
BlockGroup.TRACK_TOP_BOTTOM = new HashSet<>(
|
||||||
Material.DETECTOR_RAIL,
|
Arrays.asList(Material.POINTED_DRIPSTONE, Material.BIG_DRIPLEAF_STEM));
|
||||||
Material.FERN,
|
BlockGroup.TRACK_BOTTOM = new HashSet<>(Arrays.asList(Material.WEEPING_VINES, Material.CAVE_VINES,
|
||||||
Material.DEAD_BUSH,
|
Material.CAVE_VINES_PLANT, Material.HANGING_ROOTS));
|
||||||
Material.DANDELION,
|
|
||||||
Material.POPPY,
|
|
||||||
Material.BLUE_ORCHID,
|
|
||||||
Material.ALLIUM,
|
|
||||||
Material.AZURE_BLUET,
|
|
||||||
Material.RED_TULIP,
|
|
||||||
Material.ORANGE_TULIP,
|
|
||||||
Material.WHITE_TULIP,
|
|
||||||
Material.PINK_TULIP,
|
|
||||||
Material.OXEYE_DAISY,
|
|
||||||
Material.BROWN_MUSHROOM,
|
|
||||||
Material.RED_MUSHROOM,
|
|
||||||
Material.REDSTONE_WIRE,
|
|
||||||
Material.WHEAT,
|
|
||||||
Material.ACACIA_SIGN,
|
|
||||||
Material.BIRCH_SIGN,
|
|
||||||
Material.DARK_OAK_SIGN,
|
|
||||||
Material.JUNGLE_SIGN,
|
|
||||||
Material.OAK_SIGN,
|
|
||||||
Material.SPRUCE_SIGN,
|
|
||||||
Material.WHITE_BANNER,
|
|
||||||
Material.ORANGE_BANNER,
|
|
||||||
Material.MAGENTA_BANNER,
|
|
||||||
Material.LIGHT_BLUE_BANNER,
|
|
||||||
Material.YELLOW_BANNER,
|
|
||||||
Material.LIME_BANNER,
|
|
||||||
Material.PINK_BANNER,
|
|
||||||
Material.GRAY_BANNER,
|
|
||||||
Material.LIGHT_GRAY_BANNER,
|
|
||||||
Material.CYAN_BANNER,
|
|
||||||
Material.PURPLE_BANNER,
|
|
||||||
Material.BLUE_BANNER,
|
|
||||||
Material.BROWN_BANNER,
|
|
||||||
Material.GREEN_BANNER,
|
|
||||||
Material.RED_BANNER,
|
|
||||||
Material.BLACK_BANNER,
|
|
||||||
Material.RAIL,
|
|
||||||
Material.IRON_DOOR,
|
|
||||||
Material.SNOW,
|
|
||||||
Material.CACTUS,
|
|
||||||
Material.SUGAR_CANE,
|
|
||||||
Material.REPEATER,
|
|
||||||
Material.PUMPKIN_STEM,
|
|
||||||
Material.MELON_STEM,
|
|
||||||
Material.CARROT,
|
|
||||||
Material.POTATO,
|
|
||||||
Material.COMPARATOR,
|
|
||||||
Material.ACTIVATOR_RAIL,
|
|
||||||
Material.SUNFLOWER,
|
|
||||||
Material.LILAC,
|
|
||||||
Material.TALL_GRASS,
|
|
||||||
Material.LARGE_FERN,
|
|
||||||
Material.ROSE_BUSH,
|
|
||||||
Material.PEONY,
|
|
||||||
Material.NETHER_WART,
|
|
||||||
Material.CHORUS_PLANT,
|
|
||||||
Material.CHORUS_FLOWER,
|
|
||||||
Material.KELP,
|
|
||||||
Material.SOUL_TORCH,
|
|
||||||
Material.TWISTING_VINES,
|
|
||||||
Material.CRIMSON_FUNGUS,
|
|
||||||
Material.WARPED_FUNGUS,
|
|
||||||
Material.CRIMSON_ROOTS,
|
|
||||||
Material.WARPED_ROOTS,
|
|
||||||
Material.NETHER_SPROUTS,
|
|
||||||
Material.CRIMSON_SIGN,
|
|
||||||
Material.WARPED_SIGN,
|
|
||||||
Material.AZALEA,
|
|
||||||
Material.FLOWERING_AZALEA,
|
|
||||||
Material.SMALL_DRIPLEAF,
|
|
||||||
Material.BIG_DRIPLEAF));
|
|
||||||
BlockGroup.TRACK_TOP_BOTTOM =
|
|
||||||
new HashSet<>(Arrays.asList(Material.POINTED_DRIPSTONE, Material.BIG_DRIPLEAF_STEM));
|
|
||||||
BlockGroup.TRACK_BOTTOM = new HashSet<>(Arrays.asList(
|
|
||||||
Material.WEEPING_VINES, Material.CAVE_VINES, Material.CAVE_VINES_PLANT, Material.HANGING_ROOTS));
|
|
||||||
BlockGroup.VINES = new HashSet<>(
|
BlockGroup.VINES = new HashSet<>(
|
||||||
Arrays.asList(Material.VINE, Material.WEEPING_VINES, Material.TWISTING_VINES, Material.CAVE_VINES));
|
Arrays.asList(Material.VINE, Material.WEEPING_VINES, Material.TWISTING_VINES, Material.CAVE_VINES));
|
||||||
BlockGroup.CANDLES = new HashSet<>(Arrays.asList(
|
BlockGroup.CANDLES = new HashSet<>(Arrays.asList(Material.CANDLE, Material.BLACK_CANDLE, Material.BLUE_CANDLE,
|
||||||
Material.CANDLE,
|
Material.BROWN_CANDLE, Material.CYAN_CANDLE, Material.GRAY_CANDLE, Material.GREEN_CANDLE,
|
||||||
Material.BLACK_CANDLE,
|
Material.LIGHT_BLUE_CANDLE, Material.LIGHT_GRAY_CANDLE, Material.LIME_CANDLE, Material.MAGENTA_CANDLE,
|
||||||
Material.BLUE_CANDLE,
|
Material.ORANGE_CANDLE, Material.PINK_CANDLE, Material.PURPLE_CANDLE, Material.RED_CANDLE,
|
||||||
Material.BROWN_CANDLE,
|
Material.WHITE_CANDLE, Material.YELLOW_CANDLE, Material.CANDLE_CAKE, Material.BLACK_CANDLE_CAKE,
|
||||||
Material.CYAN_CANDLE,
|
Material.BLUE_CANDLE_CAKE, Material.BROWN_CANDLE_CAKE, Material.CYAN_CANDLE_CAKE,
|
||||||
Material.GRAY_CANDLE,
|
Material.GRAY_CANDLE_CAKE, Material.GREEN_CANDLE_CAKE, Material.LIGHT_BLUE_CANDLE_CAKE,
|
||||||
Material.GREEN_CANDLE,
|
Material.LIGHT_GRAY_CANDLE_CAKE, Material.LIME_CANDLE_CAKE, Material.MAGENTA_CANDLE_CAKE,
|
||||||
Material.LIGHT_BLUE_CANDLE,
|
Material.ORANGE_CANDLE_CAKE, Material.PINK_CANDLE_CAKE, Material.PURPLE_CANDLE_CAKE,
|
||||||
Material.LIGHT_GRAY_CANDLE,
|
Material.RED_CANDLE_CAKE, Material.WHITE_CANDLE_CAKE, Material.YELLOW_CANDLE_CAKE));
|
||||||
Material.LIME_CANDLE,
|
BlockGroup.AMETHYST = new HashSet<>(Arrays.asList(Material.SMALL_AMETHYST_BUD, Material.MEDIUM_AMETHYST_BUD,
|
||||||
Material.MAGENTA_CANDLE,
|
Material.LARGE_AMETHYST_BUD, Material.AMETHYST_CLUSTER));
|
||||||
Material.ORANGE_CANDLE,
|
BlockGroup.UPDATE_STATE = new HashSet<>(Arrays.asList(Material.TORCH, Material.WALL_TORCH,
|
||||||
Material.PINK_CANDLE,
|
Material.REDSTONE_WIRE, Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FURNACE,
|
||||||
Material.PURPLE_CANDLE,
|
Material.BLAST_FURNACE, Material.SMOKER, Material.LEVER, Material.REDSTONE_TORCH,
|
||||||
Material.RED_CANDLE,
|
Material.REDSTONE_WALL_TORCH, Material.GLOWSTONE, Material.JACK_O_LANTERN, Material.REPEATER,
|
||||||
Material.WHITE_CANDLE,
|
Material.REDSTONE_LAMP, Material.BEACON, Material.COMPARATOR, Material.DAYLIGHT_DETECTOR,
|
||||||
Material.YELLOW_CANDLE,
|
Material.REDSTONE_BLOCK, Material.HOPPER, Material.CHEST, Material.TRAPPED_CHEST,
|
||||||
Material.CANDLE_CAKE,
|
Material.ACTIVATOR_RAIL, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.SHROOMLIGHT,
|
||||||
Material.BLACK_CANDLE_CAKE,
|
Material.RESPAWN_ANCHOR, Material.CRYING_OBSIDIAN, Material.TARGET, Material.SMALL_AMETHYST_BUD,
|
||||||
Material.BLUE_CANDLE_CAKE,
|
Material.MEDIUM_AMETHYST_BUD, Material.LARGE_AMETHYST_BUD, Material.AMETHYST_CLUSTER,
|
||||||
Material.BROWN_CANDLE_CAKE,
|
Material.CAVE_VINES, Material.CAVE_VINES_PLANT, Material.GLOW_LICHEN, Material.LIGHT,
|
||||||
Material.CYAN_CANDLE_CAKE,
|
|
||||||
Material.GRAY_CANDLE_CAKE,
|
|
||||||
Material.GREEN_CANDLE_CAKE,
|
|
||||||
Material.LIGHT_BLUE_CANDLE_CAKE,
|
|
||||||
Material.LIGHT_GRAY_CANDLE_CAKE,
|
|
||||||
Material.LIME_CANDLE_CAKE,
|
|
||||||
Material.MAGENTA_CANDLE_CAKE,
|
|
||||||
Material.ORANGE_CANDLE_CAKE,
|
|
||||||
Material.PINK_CANDLE_CAKE,
|
|
||||||
Material.PURPLE_CANDLE_CAKE,
|
|
||||||
Material.RED_CANDLE_CAKE,
|
|
||||||
Material.WHITE_CANDLE_CAKE,
|
|
||||||
Material.YELLOW_CANDLE_CAKE));
|
|
||||||
BlockGroup.AMETHYST = new HashSet<>(Arrays.asList(
|
|
||||||
Material.SMALL_AMETHYST_BUD,
|
|
||||||
Material.MEDIUM_AMETHYST_BUD,
|
|
||||||
Material.LARGE_AMETHYST_BUD,
|
|
||||||
Material.AMETHYST_CLUSTER));
|
|
||||||
BlockGroup.UPDATE_STATE = new HashSet<>(Arrays.asList(
|
|
||||||
Material.TORCH,
|
|
||||||
Material.WALL_TORCH,
|
|
||||||
Material.REDSTONE_WIRE,
|
|
||||||
Material.RAIL,
|
|
||||||
Material.POWERED_RAIL,
|
|
||||||
Material.DETECTOR_RAIL,
|
|
||||||
Material.FURNACE,
|
|
||||||
Material.BLAST_FURNACE,
|
|
||||||
Material.SMOKER,
|
|
||||||
Material.LEVER,
|
|
||||||
Material.REDSTONE_TORCH,
|
|
||||||
Material.REDSTONE_WALL_TORCH,
|
|
||||||
Material.GLOWSTONE,
|
|
||||||
Material.JACK_O_LANTERN,
|
|
||||||
Material.REPEATER,
|
|
||||||
Material.REDSTONE_LAMP,
|
|
||||||
Material.BEACON,
|
|
||||||
Material.COMPARATOR,
|
|
||||||
Material.DAYLIGHT_DETECTOR,
|
|
||||||
Material.REDSTONE_BLOCK,
|
|
||||||
Material.HOPPER,
|
|
||||||
Material.CHEST,
|
|
||||||
Material.TRAPPED_CHEST,
|
|
||||||
Material.ACTIVATOR_RAIL,
|
|
||||||
Material.SOUL_TORCH,
|
|
||||||
Material.SOUL_WALL_TORCH,
|
|
||||||
Material.SHROOMLIGHT,
|
|
||||||
Material.RESPAWN_ANCHOR,
|
|
||||||
Material.CRYING_OBSIDIAN,
|
|
||||||
Material.TARGET,
|
|
||||||
Material.SMALL_AMETHYST_BUD,
|
|
||||||
Material.MEDIUM_AMETHYST_BUD,
|
|
||||||
Material.LARGE_AMETHYST_BUD,
|
|
||||||
Material.AMETHYST_CLUSTER,
|
|
||||||
Material.CAVE_VINES,
|
|
||||||
Material.CAVE_VINES_PLANT,
|
|
||||||
Material.GLOW_LICHEN,
|
|
||||||
Material.LIGHT,
|
|
||||||
Material.LAVA_CAULDRON));
|
Material.LAVA_CAULDRON));
|
||||||
BlockGroup.NON_ATTACHABLE = new HashSet<>(Arrays.asList(
|
BlockGroup.NON_ATTACHABLE = new HashSet<>(Arrays.asList(Material.AIR, Material.CAVE_AIR, Material.BARRIER,
|
||||||
Material.AIR,
|
Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH,
|
||||||
Material.CAVE_AIR,
|
Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING,
|
||||||
Material.BARRIER,
|
Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.WATER, Material.LAVA,
|
||||||
Material.CORNFLOWER,
|
Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH, Material.DANDELION,
|
||||||
Material.LILY_OF_THE_VALLEY,
|
Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP,
|
||||||
Material.WITHER_ROSE,
|
Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY,
|
||||||
Material.SWEET_BERRY_BUSH,
|
Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH, Material.WALL_TORCH,
|
||||||
Material.OAK_SAPLING,
|
Material.REDSTONE_WIRE, Material.LADDER, Material.RAIL, Material.LEVER, Material.REDSTONE_TORCH,
|
||||||
Material.SPRUCE_SAPLING,
|
Material.REDSTONE_WALL_TORCH, Material.SNOW, Material.SUGAR_CANE, Material.NETHER_PORTAL,
|
||||||
Material.BIRCH_SAPLING,
|
Material.REPEATER, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.SOUL_TORCH,
|
||||||
Material.JUNGLE_SAPLING,
|
Material.SOUL_WALL_TORCH, Material.LIGHT, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF,
|
||||||
Material.ACACIA_SAPLING,
|
Material.BIG_DRIPLEAF_STEM, Material.GLOW_LICHEN, Material.HANGING_ROOTS));
|
||||||
Material.DARK_OAK_SAPLING,
|
|
||||||
Material.WATER,
|
|
||||||
Material.LAVA,
|
|
||||||
Material.POWERED_RAIL,
|
|
||||||
Material.DETECTOR_RAIL,
|
|
||||||
Material.FERN,
|
|
||||||
Material.DEAD_BUSH,
|
|
||||||
Material.DANDELION,
|
|
||||||
Material.POPPY,
|
|
||||||
Material.BLUE_ORCHID,
|
|
||||||
Material.ALLIUM,
|
|
||||||
Material.AZURE_BLUET,
|
|
||||||
Material.RED_TULIP,
|
|
||||||
Material.ORANGE_TULIP,
|
|
||||||
Material.WHITE_TULIP,
|
|
||||||
Material.PINK_TULIP,
|
|
||||||
Material.OXEYE_DAISY,
|
|
||||||
Material.BROWN_MUSHROOM,
|
|
||||||
Material.RED_MUSHROOM,
|
|
||||||
Material.TORCH,
|
|
||||||
Material.WALL_TORCH,
|
|
||||||
Material.REDSTONE_WIRE,
|
|
||||||
Material.LADDER,
|
|
||||||
Material.RAIL,
|
|
||||||
Material.LEVER,
|
|
||||||
Material.REDSTONE_TORCH,
|
|
||||||
Material.REDSTONE_WALL_TORCH,
|
|
||||||
Material.SNOW,
|
|
||||||
Material.SUGAR_CANE,
|
|
||||||
Material.NETHER_PORTAL,
|
|
||||||
Material.REPEATER,
|
|
||||||
Material.KELP,
|
|
||||||
Material.CHORUS_FLOWER,
|
|
||||||
Material.CHORUS_PLANT,
|
|
||||||
Material.SOUL_TORCH,
|
|
||||||
Material.SOUL_WALL_TORCH,
|
|
||||||
Material.LIGHT,
|
|
||||||
Material.SMALL_DRIPLEAF,
|
|
||||||
Material.BIG_DRIPLEAF,
|
|
||||||
Material.BIG_DRIPLEAF_STEM,
|
|
||||||
Material.GLOW_LICHEN,
|
|
||||||
Material.HANGING_ROOTS));
|
|
||||||
BlockGroup.VERTICAL_TOP_BOTTOM = new HashSet<>(Arrays.asList(Material.BIG_DRIPLEAF_STEM));
|
BlockGroup.VERTICAL_TOP_BOTTOM = new HashSet<>(Arrays.asList(Material.BIG_DRIPLEAF_STEM));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String parseLegacyName(String name) {
|
public String parseLegacyName(String name) {
|
||||||
|
|
||||||
switch (name) {
|
switch (name) {
|
||||||
|
|
||||||
case "GRASS_PATH":
|
case "GRASS_PATH":
|
||||||
name = "DIRT_PATH";
|
name = "DIRT_PATH";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLegacyBlockId(Material material) {
|
public int getLegacyBlockId(Material material) {
|
||||||
|
|
||||||
switch (material) {
|
switch (material) {
|
||||||
|
|
||||||
case DIRT_PATH:
|
case DIRT_PATH:
|
||||||
return Util.getBlockId("GRASS_PATH", false);
|
return Util.getBlockId("GRASS_PATH", false);
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getEntityMeta(LivingEntity entity, List<Object> info) {
|
public boolean getEntityMeta(LivingEntity entity, List<Object> info) {
|
||||||
|
|
||||||
if (entity instanceof Axolotl) {
|
if (entity instanceof Axolotl) {
|
||||||
|
|
||||||
Axolotl axolotl = (Axolotl) entity;
|
Axolotl axolotl = (Axolotl) entity;
|
||||||
info.add(axolotl.getVariant());
|
info.add(axolotl.getVariant());
|
||||||
|
|
||||||
} else if (entity instanceof Goat) {
|
} else if (entity instanceof Goat) {
|
||||||
|
|
||||||
Goat goat = (Goat) entity;
|
Goat goat = (Goat) entity;
|
||||||
info.add(goat.isScreaming());
|
info.add(goat.isScreaming());
|
||||||
|
|
||||||
} else if (super.getEntityMeta(entity, info)) {
|
} else if (super.getEntityMeta(entity, info)) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setEntityMeta(Entity entity, Object value, int count) {
|
public boolean setEntityMeta(Entity entity, Object value, int count) {
|
||||||
|
|
||||||
if (entity instanceof Axolotl) {
|
if (entity instanceof Axolotl) {
|
||||||
|
|
||||||
Axolotl axolotl = (Axolotl) entity;
|
Axolotl axolotl = (Axolotl) entity;
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
|
|
||||||
org.bukkit.entity.Axolotl.Variant set = (org.bukkit.entity.Axolotl.Variant) value;
|
org.bukkit.entity.Axolotl.Variant set = (org.bukkit.entity.Axolotl.Variant) value;
|
||||||
axolotl.setVariant(set);
|
axolotl.setVariant(set);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (entity instanceof Goat) {
|
} else if (entity instanceof Goat) {
|
||||||
|
|
||||||
Goat goat = (Goat) entity;
|
Goat goat = (Goat) entity;
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
|
|
||||||
boolean set = (Boolean) value;
|
boolean set = (Boolean) value;
|
||||||
goat.setScreaming(set);
|
goat.setScreaming(set);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (super.setEntityMeta(entity, value, count)) {
|
} else if (super.setEntityMeta(entity, value, count)) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getItemMeta(
|
public boolean getItemMeta(ItemMeta itemMeta, List<Map<String, Object>> list,
|
||||||
ItemMeta itemMeta, List<Map<String, Object>> list, List<List<Map<String, Object>>> metadata, int slot) {
|
List<List<Map<String, Object>>> metadata, int slot)
|
||||||
|
{
|
||||||
|
|
||||||
if (itemMeta instanceof BundleMeta) {
|
if (itemMeta instanceof BundleMeta) {
|
||||||
|
|
||||||
BundleMeta meta = (BundleMeta) itemMeta;
|
BundleMeta meta = (BundleMeta) itemMeta;
|
||||||
BundleMeta subMeta = (BundleMeta) meta.clone();
|
BundleMeta subMeta = (BundleMeta) meta.clone();
|
||||||
meta.setItems(null);
|
meta.setItems(null);
|
||||||
@@ -346,120 +208,177 @@ public class Bukkit_v1_17 extends BukkitAdapter implements BukkitInterface {
|
|||||||
metadata.add(list);
|
metadata.add(list);
|
||||||
|
|
||||||
if (subMeta.hasItems()) {
|
if (subMeta.hasItems()) {
|
||||||
|
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
for (ItemStack itemStack : subMeta.getItems()) {
|
for (ItemStack itemStack : subMeta.getItems()) {
|
||||||
|
|
||||||
Map<String, Object> itemMap = Util.serializeItemStack(itemStack, null, slot);
|
Map<String, Object> itemMap = Util.serializeItemStack(itemStack, null, slot);
|
||||||
if (itemMap.size() > 0) {
|
if (itemMap.size() > 0) {
|
||||||
|
|
||||||
list.add(itemMap);
|
list.add(itemMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata.add(list);
|
metadata.add(list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (super.getItemMeta(itemMeta, list, metadata, slot)) {
|
} else if (super.getItemMeta(itemMeta, list, metadata, slot)) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setItemMeta(Material rowType, ItemStack itemstack, List<Map<String, Object>> map) {
|
public boolean setItemMeta(Material rowType, ItemStack itemstack, List<Map<String, Object>> map) {
|
||||||
|
|
||||||
if ((rowType == Material.BUNDLE)) {
|
if ((rowType == Material.BUNDLE)) {
|
||||||
|
|
||||||
BundleMeta meta = (BundleMeta) itemstack.getItemMeta();
|
BundleMeta meta = (BundleMeta) itemstack.getItemMeta();
|
||||||
for (Map<String, Object> itemData : map) {
|
for (Map<String, Object> itemData : map) {
|
||||||
|
|
||||||
ItemStack itemStack = Util.unserializeItemStack(itemData);
|
ItemStack itemStack = Util.unserializeItemStack(itemData);
|
||||||
if (itemStack != null) {
|
if (itemStack != null) {
|
||||||
|
|
||||||
meta.addItem(itemStack);
|
meta.addItem(itemStack);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
} else if (super.setItemMeta(rowType, itemstack, map)) {
|
} else if (super.setItemMeta(rowType, itemstack, map)) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAttached(Block block, Block scanBlock, BlockData blockData, int scanMin) {
|
public boolean isAttached(Block block, Block scanBlock, BlockData blockData, int scanMin) {
|
||||||
|
|
||||||
if (blockData instanceof PointedDripstone) {
|
if (blockData instanceof PointedDripstone) {
|
||||||
|
|
||||||
PointedDripstone pointedDripstone = (PointedDripstone) blockData;
|
PointedDripstone pointedDripstone = (PointedDripstone) blockData;
|
||||||
BlockFace blockFace = pointedDripstone.getVerticalDirection();
|
BlockFace blockFace = pointedDripstone.getVerticalDirection();
|
||||||
boolean adjacent = scanBlock
|
boolean adjacent = scanBlock.getRelative(blockFace.getOppositeFace()).getLocation()
|
||||||
.getRelative(blockFace.getOppositeFace())
|
|
||||||
.getLocation()
|
|
||||||
.equals(block.getLocation());
|
.equals(block.getLocation());
|
||||||
if (!adjacent) {
|
if (!adjacent) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!super.isAttached(block, scanBlock, blockData, scanMin)) {
|
} else if (!super.isAttached(block, scanBlock, blockData, scanMin)) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMinHeight(World world) {
|
public int getMinHeight(World world) {
|
||||||
|
|
||||||
return world.getMinHeight();
|
return world.getMinHeight();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Material getBucketContents(Material material) {
|
public Material getBucketContents(Material material) {
|
||||||
|
|
||||||
return (material == Material.POWDER_SNOW_BUCKET ? Material.POWDER_SNOW : Material.AIR);
|
return (material == Material.POWDER_SNOW_BUCKET ? Material.POWDER_SNOW : Material.AIR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemFrame(Material material) {
|
public boolean isItemFrame(Material material) {
|
||||||
|
|
||||||
return (material == Material.ITEM_FRAME || material == Material.GLOW_ITEM_FRAME);
|
return (material == Material.ITEM_FRAME || material == Material.GLOW_ITEM_FRAME);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Material getFrameType(Entity entity) {
|
public Material getFrameType(Entity entity) {
|
||||||
|
|
||||||
return (entity instanceof GlowItemFrame) ? Material.GLOW_ITEM_FRAME : Material.ITEM_FRAME;
|
return (entity instanceof GlowItemFrame) ? Material.GLOW_ITEM_FRAME : Material.ITEM_FRAME;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Material getFrameType(EntityType type) {
|
public Material getFrameType(EntityType type) {
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
||||||
case ITEM_FRAME:
|
case ITEM_FRAME:
|
||||||
return Material.ITEM_FRAME;
|
return Material.ITEM_FRAME;
|
||||||
case GLOW_ITEM_FRAME:
|
case GLOW_ITEM_FRAME:
|
||||||
return Material.GLOW_ITEM_FRAME;
|
return Material.GLOW_ITEM_FRAME;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getFrameClass(Material material) {
|
public Class<?> getFrameClass(Material material) {
|
||||||
|
|
||||||
return (material == Material.GLOW_ITEM_FRAME) ? GlowItemFrame.class : ItemFrame.class;
|
return (material == Material.GLOW_ITEM_FRAME) ? GlowItemFrame.class : ItemFrame.class;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGlowing(Sign sign, boolean isFront) {
|
public boolean isGlowing(Sign sign, boolean isFront) {
|
||||||
|
|
||||||
if (!isFront) {
|
if (!isFront) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sign.isGlowingText();
|
return sign.isGlowingText();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGlowing(Sign sign, boolean isFront, boolean isGlowing) {
|
public void setGlowing(Sign sign, boolean isFront, boolean isGlowing) {
|
||||||
|
|
||||||
if (!isFront) {
|
if (!isFront) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sign.setGlowingText(isGlowing);
|
sign.setGlowingText(isGlowing);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvisible(Material material) {
|
public boolean isInvisible(Material material) {
|
||||||
|
|
||||||
return material.isAir() || material == Material.LIGHT;
|
return material.isAir() || material == Material.LIGHT;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,20 +9,31 @@ public class Bukkit_v1_18 extends Bukkit_v1_17 implements BukkitInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack adjustIngredient(MerchantRecipe recipe, ItemStack itemStack) {
|
public ItemStack adjustIngredient(MerchantRecipe recipe, ItemStack itemStack) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (hasAdjust == null) {
|
if (hasAdjust == null) {
|
||||||
|
|
||||||
hasAdjust = true;
|
hasAdjust = true;
|
||||||
MerchantRecipe.class.getMethod("adjust", ItemStack.class); // Bukkit 1.18.1+
|
MerchantRecipe.class.getMethod("adjust", ItemStack.class); // Bukkit 1.18.1+
|
||||||
|
|
||||||
} else if (Boolean.FALSE.equals(hasAdjust)) {
|
} else if (Boolean.FALSE.equals(hasAdjust)) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack adjustedStack = itemStack.clone();
|
ItemStack adjustedStack = itemStack.clone();
|
||||||
recipe.adjust(adjustedStack);
|
recipe.adjust(adjustedStack);
|
||||||
return adjustedStack;
|
return adjustedStack;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
hasAdjust = false;
|
hasAdjust = false;
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -14,384 +14,191 @@ import org.bukkit.entity.Tadpole;
|
|||||||
public class Bukkit_v1_19 extends Bukkit_v1_18 implements BukkitInterface {
|
public class Bukkit_v1_19 extends Bukkit_v1_18 implements BukkitInterface {
|
||||||
|
|
||||||
public Bukkit_v1_19() {
|
public Bukkit_v1_19() {
|
||||||
BlockGroup.TRACK_TOP = new HashSet<>(Arrays.asList(
|
|
||||||
Material.TORCH,
|
BlockGroup.TRACK_TOP = new HashSet<>(Arrays.asList(Material.TORCH, Material.REDSTONE_TORCH, Material.BAMBOO,
|
||||||
Material.REDSTONE_TORCH,
|
Material.BAMBOO_SAPLING, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE,
|
||||||
Material.BAMBOO,
|
Material.SWEET_BERRY_BUSH, Material.SCAFFOLDING, Material.OAK_SAPLING, Material.SPRUCE_SAPLING,
|
||||||
Material.BAMBOO_SAPLING,
|
Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING, Material.MANGROVE_PROPAGULE, Material.ACACIA_SAPLING,
|
||||||
Material.CORNFLOWER,
|
Material.DARK_OAK_SAPLING, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN,
|
||||||
Material.LILY_OF_THE_VALLEY,
|
Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM,
|
||||||
Material.WITHER_ROSE,
|
Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP,
|
||||||
Material.SWEET_BERRY_BUSH,
|
Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM,
|
||||||
Material.SCAFFOLDING,
|
Material.REDSTONE_WIRE, Material.WHEAT, Material.MANGROVE_SIGN, Material.ACACIA_SIGN,
|
||||||
Material.OAK_SAPLING,
|
Material.BIRCH_SIGN, Material.DARK_OAK_SIGN, Material.JUNGLE_SIGN, Material.OAK_SIGN,
|
||||||
Material.SPRUCE_SAPLING,
|
Material.SPRUCE_SIGN, Material.WHITE_BANNER, Material.ORANGE_BANNER, Material.MAGENTA_BANNER,
|
||||||
Material.BIRCH_SAPLING,
|
Material.LIGHT_BLUE_BANNER, Material.YELLOW_BANNER, Material.LIME_BANNER, Material.PINK_BANNER,
|
||||||
Material.JUNGLE_SAPLING,
|
Material.GRAY_BANNER, Material.LIGHT_GRAY_BANNER, Material.CYAN_BANNER, Material.PURPLE_BANNER,
|
||||||
Material.MANGROVE_PROPAGULE,
|
Material.BLUE_BANNER, Material.BROWN_BANNER, Material.GREEN_BANNER, Material.RED_BANNER,
|
||||||
Material.ACACIA_SAPLING,
|
Material.BLACK_BANNER, Material.RAIL, Material.IRON_DOOR, Material.SNOW, Material.CACTUS,
|
||||||
Material.DARK_OAK_SAPLING,
|
Material.SUGAR_CANE, Material.REPEATER, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.CARROT,
|
||||||
Material.POWERED_RAIL,
|
Material.POTATO, Material.COMPARATOR, Material.ACTIVATOR_RAIL, Material.SUNFLOWER, Material.LILAC,
|
||||||
Material.DETECTOR_RAIL,
|
Material.TALL_GRASS, Material.LARGE_FERN, Material.ROSE_BUSH, Material.PEONY, Material.NETHER_WART,
|
||||||
Material.FERN,
|
Material.CHORUS_PLANT, Material.CHORUS_FLOWER, Material.KELP, Material.SOUL_TORCH,
|
||||||
Material.DEAD_BUSH,
|
Material.TWISTING_VINES, Material.CRIMSON_FUNGUS, Material.WARPED_FUNGUS, Material.CRIMSON_ROOTS,
|
||||||
Material.DANDELION,
|
Material.WARPED_ROOTS, Material.NETHER_SPROUTS, Material.CRIMSON_SIGN, Material.WARPED_SIGN,
|
||||||
Material.POPPY,
|
Material.AZALEA, Material.FLOWERING_AZALEA, Material.SMALL_DRIPLEAF, Material.BIG_DRIPLEAF));
|
||||||
Material.BLUE_ORCHID,
|
BlockGroup.TRACK_SIDE = new HashSet<>(Arrays.asList(Material.WALL_TORCH, Material.REDSTONE_WALL_TORCH,
|
||||||
Material.ALLIUM,
|
Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.ACTIVATOR_RAIL,
|
||||||
Material.AZURE_BLUET,
|
Material.WHITE_BED, Material.ORANGE_BED, Material.MAGENTA_BED, Material.LIGHT_BLUE_BED,
|
||||||
Material.RED_TULIP,
|
Material.YELLOW_BED, Material.LIME_BED, Material.PINK_BED, Material.GRAY_BED, Material.LIGHT_GRAY_BED,
|
||||||
Material.ORANGE_TULIP,
|
Material.CYAN_BED, Material.PURPLE_BED, Material.BLUE_BED, Material.BROWN_BED, Material.GREEN_BED,
|
||||||
Material.WHITE_TULIP,
|
Material.RED_BED, Material.BLACK_BED, Material.LADDER, Material.MANGROVE_WALL_SIGN,
|
||||||
Material.PINK_TULIP,
|
Material.ACACIA_WALL_SIGN, Material.BIRCH_WALL_SIGN, Material.DARK_OAK_WALL_SIGN,
|
||||||
Material.OXEYE_DAISY,
|
Material.JUNGLE_WALL_SIGN, Material.OAK_WALL_SIGN, Material.SPRUCE_WALL_SIGN, Material.VINE,
|
||||||
Material.BROWN_MUSHROOM,
|
Material.COCOA, Material.TRIPWIRE_HOOK, Material.WHITE_WALL_BANNER, Material.ORANGE_WALL_BANNER,
|
||||||
Material.RED_MUSHROOM,
|
Material.MAGENTA_WALL_BANNER, Material.LIGHT_BLUE_WALL_BANNER, Material.YELLOW_WALL_BANNER,
|
||||||
Material.REDSTONE_WIRE,
|
Material.LIME_WALL_BANNER, Material.PINK_WALL_BANNER, Material.GRAY_WALL_BANNER,
|
||||||
Material.WHEAT,
|
Material.LIGHT_GRAY_WALL_BANNER, Material.CYAN_WALL_BANNER, Material.PURPLE_WALL_BANNER,
|
||||||
Material.MANGROVE_SIGN,
|
Material.BLUE_WALL_BANNER, Material.BROWN_WALL_BANNER, Material.GREEN_WALL_BANNER,
|
||||||
Material.ACACIA_SIGN,
|
Material.RED_WALL_BANNER, Material.BLACK_WALL_BANNER, Material.SOUL_WALL_TORCH,
|
||||||
Material.BIRCH_SIGN,
|
Material.CRIMSON_WALL_SIGN, Material.WARPED_WALL_SIGN));
|
||||||
Material.DARK_OAK_SIGN,
|
BlockGroup.DOORS = new HashSet<>(Arrays.asList(Material.OAK_DOOR, Material.SPRUCE_DOOR, Material.BIRCH_DOOR,
|
||||||
Material.JUNGLE_SIGN,
|
Material.JUNGLE_DOOR, Material.MANGROVE_DOOR, Material.ACACIA_DOOR, Material.DARK_OAK_DOOR,
|
||||||
Material.OAK_SIGN,
|
Material.CRIMSON_DOOR, Material.WARPED_DOOR));
|
||||||
Material.SPRUCE_SIGN,
|
BlockGroup.BUTTONS = new HashSet<>(Arrays.asList(Material.STONE_BUTTON, Material.OAK_BUTTON,
|
||||||
Material.WHITE_BANNER,
|
Material.MANGROVE_BUTTON, Material.ACACIA_BUTTON, Material.BIRCH_BUTTON, Material.DARK_OAK_BUTTON,
|
||||||
Material.ORANGE_BANNER,
|
Material.JUNGLE_BUTTON, Material.SPRUCE_BUTTON, Material.POLISHED_BLACKSTONE_BUTTON,
|
||||||
Material.MAGENTA_BANNER,
|
Material.CRIMSON_BUTTON, Material.WARPED_BUTTON));
|
||||||
Material.LIGHT_BLUE_BANNER,
|
BlockGroup.PRESSURE_PLATES = new HashSet<>(Arrays.asList(Material.STONE_PRESSURE_PLATE,
|
||||||
Material.YELLOW_BANNER,
|
Material.MANGROVE_PRESSURE_PLATE, Material.ACACIA_PRESSURE_PLATE, Material.BIRCH_PRESSURE_PLATE,
|
||||||
Material.LIME_BANNER,
|
Material.DARK_OAK_PRESSURE_PLATE, Material.HEAVY_WEIGHTED_PRESSURE_PLATE,
|
||||||
Material.PINK_BANNER,
|
Material.JUNGLE_PRESSURE_PLATE, Material.LIGHT_WEIGHTED_PRESSURE_PLATE, Material.OAK_PRESSURE_PLATE,
|
||||||
Material.GRAY_BANNER,
|
Material.SPRUCE_PRESSURE_PLATE, Material.CRIMSON_PRESSURE_PLATE, Material.WARPED_PRESSURE_PLATE,
|
||||||
Material.LIGHT_GRAY_BANNER,
|
|
||||||
Material.CYAN_BANNER,
|
|
||||||
Material.PURPLE_BANNER,
|
|
||||||
Material.BLUE_BANNER,
|
|
||||||
Material.BROWN_BANNER,
|
|
||||||
Material.GREEN_BANNER,
|
|
||||||
Material.RED_BANNER,
|
|
||||||
Material.BLACK_BANNER,
|
|
||||||
Material.RAIL,
|
|
||||||
Material.IRON_DOOR,
|
|
||||||
Material.SNOW,
|
|
||||||
Material.CACTUS,
|
|
||||||
Material.SUGAR_CANE,
|
|
||||||
Material.REPEATER,
|
|
||||||
Material.PUMPKIN_STEM,
|
|
||||||
Material.MELON_STEM,
|
|
||||||
Material.CARROT,
|
|
||||||
Material.POTATO,
|
|
||||||
Material.COMPARATOR,
|
|
||||||
Material.ACTIVATOR_RAIL,
|
|
||||||
Material.SUNFLOWER,
|
|
||||||
Material.LILAC,
|
|
||||||
Material.TALL_GRASS,
|
|
||||||
Material.LARGE_FERN,
|
|
||||||
Material.ROSE_BUSH,
|
|
||||||
Material.PEONY,
|
|
||||||
Material.NETHER_WART,
|
|
||||||
Material.CHORUS_PLANT,
|
|
||||||
Material.CHORUS_FLOWER,
|
|
||||||
Material.KELP,
|
|
||||||
Material.SOUL_TORCH,
|
|
||||||
Material.TWISTING_VINES,
|
|
||||||
Material.CRIMSON_FUNGUS,
|
|
||||||
Material.WARPED_FUNGUS,
|
|
||||||
Material.CRIMSON_ROOTS,
|
|
||||||
Material.WARPED_ROOTS,
|
|
||||||
Material.NETHER_SPROUTS,
|
|
||||||
Material.CRIMSON_SIGN,
|
|
||||||
Material.WARPED_SIGN,
|
|
||||||
Material.AZALEA,
|
|
||||||
Material.FLOWERING_AZALEA,
|
|
||||||
Material.SMALL_DRIPLEAF,
|
|
||||||
Material.BIG_DRIPLEAF));
|
|
||||||
BlockGroup.TRACK_SIDE = new HashSet<>(Arrays.asList(
|
|
||||||
Material.WALL_TORCH,
|
|
||||||
Material.REDSTONE_WALL_TORCH,
|
|
||||||
Material.RAIL,
|
|
||||||
Material.POWERED_RAIL,
|
|
||||||
Material.DETECTOR_RAIL,
|
|
||||||
Material.ACTIVATOR_RAIL,
|
|
||||||
Material.WHITE_BED,
|
|
||||||
Material.ORANGE_BED,
|
|
||||||
Material.MAGENTA_BED,
|
|
||||||
Material.LIGHT_BLUE_BED,
|
|
||||||
Material.YELLOW_BED,
|
|
||||||
Material.LIME_BED,
|
|
||||||
Material.PINK_BED,
|
|
||||||
Material.GRAY_BED,
|
|
||||||
Material.LIGHT_GRAY_BED,
|
|
||||||
Material.CYAN_BED,
|
|
||||||
Material.PURPLE_BED,
|
|
||||||
Material.BLUE_BED,
|
|
||||||
Material.BROWN_BED,
|
|
||||||
Material.GREEN_BED,
|
|
||||||
Material.RED_BED,
|
|
||||||
Material.BLACK_BED,
|
|
||||||
Material.LADDER,
|
|
||||||
Material.MANGROVE_WALL_SIGN,
|
|
||||||
Material.ACACIA_WALL_SIGN,
|
|
||||||
Material.BIRCH_WALL_SIGN,
|
|
||||||
Material.DARK_OAK_WALL_SIGN,
|
|
||||||
Material.JUNGLE_WALL_SIGN,
|
|
||||||
Material.OAK_WALL_SIGN,
|
|
||||||
Material.SPRUCE_WALL_SIGN,
|
|
||||||
Material.VINE,
|
|
||||||
Material.COCOA,
|
|
||||||
Material.TRIPWIRE_HOOK,
|
|
||||||
Material.WHITE_WALL_BANNER,
|
|
||||||
Material.ORANGE_WALL_BANNER,
|
|
||||||
Material.MAGENTA_WALL_BANNER,
|
|
||||||
Material.LIGHT_BLUE_WALL_BANNER,
|
|
||||||
Material.YELLOW_WALL_BANNER,
|
|
||||||
Material.LIME_WALL_BANNER,
|
|
||||||
Material.PINK_WALL_BANNER,
|
|
||||||
Material.GRAY_WALL_BANNER,
|
|
||||||
Material.LIGHT_GRAY_WALL_BANNER,
|
|
||||||
Material.CYAN_WALL_BANNER,
|
|
||||||
Material.PURPLE_WALL_BANNER,
|
|
||||||
Material.BLUE_WALL_BANNER,
|
|
||||||
Material.BROWN_WALL_BANNER,
|
|
||||||
Material.GREEN_WALL_BANNER,
|
|
||||||
Material.RED_WALL_BANNER,
|
|
||||||
Material.BLACK_WALL_BANNER,
|
|
||||||
Material.SOUL_WALL_TORCH,
|
|
||||||
Material.CRIMSON_WALL_SIGN,
|
|
||||||
Material.WARPED_WALL_SIGN));
|
|
||||||
BlockGroup.DOORS = new HashSet<>(Arrays.asList(
|
|
||||||
Material.OAK_DOOR,
|
|
||||||
Material.SPRUCE_DOOR,
|
|
||||||
Material.BIRCH_DOOR,
|
|
||||||
Material.JUNGLE_DOOR,
|
|
||||||
Material.MANGROVE_DOOR,
|
|
||||||
Material.ACACIA_DOOR,
|
|
||||||
Material.DARK_OAK_DOOR,
|
|
||||||
Material.CRIMSON_DOOR,
|
|
||||||
Material.WARPED_DOOR));
|
|
||||||
BlockGroup.BUTTONS = new HashSet<>(Arrays.asList(
|
|
||||||
Material.STONE_BUTTON,
|
|
||||||
Material.OAK_BUTTON,
|
|
||||||
Material.MANGROVE_BUTTON,
|
|
||||||
Material.ACACIA_BUTTON,
|
|
||||||
Material.BIRCH_BUTTON,
|
|
||||||
Material.DARK_OAK_BUTTON,
|
|
||||||
Material.JUNGLE_BUTTON,
|
|
||||||
Material.SPRUCE_BUTTON,
|
|
||||||
Material.POLISHED_BLACKSTONE_BUTTON,
|
|
||||||
Material.CRIMSON_BUTTON,
|
|
||||||
Material.WARPED_BUTTON));
|
|
||||||
BlockGroup.PRESSURE_PLATES = new HashSet<>(Arrays.asList(
|
|
||||||
Material.STONE_PRESSURE_PLATE,
|
|
||||||
Material.MANGROVE_PRESSURE_PLATE,
|
|
||||||
Material.ACACIA_PRESSURE_PLATE,
|
|
||||||
Material.BIRCH_PRESSURE_PLATE,
|
|
||||||
Material.DARK_OAK_PRESSURE_PLATE,
|
|
||||||
Material.HEAVY_WEIGHTED_PRESSURE_PLATE,
|
|
||||||
Material.JUNGLE_PRESSURE_PLATE,
|
|
||||||
Material.LIGHT_WEIGHTED_PRESSURE_PLATE,
|
|
||||||
Material.OAK_PRESSURE_PLATE,
|
|
||||||
Material.SPRUCE_PRESSURE_PLATE,
|
|
||||||
Material.CRIMSON_PRESSURE_PLATE,
|
|
||||||
Material.WARPED_PRESSURE_PLATE,
|
|
||||||
Material.POLISHED_BLACKSTONE_PRESSURE_PLATE));
|
Material.POLISHED_BLACKSTONE_PRESSURE_PLATE));
|
||||||
BlockGroup.INTERACT_BLOCKS = new HashSet<>(Arrays.asList(
|
BlockGroup.INTERACT_BLOCKS = new HashSet<>(Arrays.asList(Material.SPRUCE_FENCE_GATE, Material.BIRCH_FENCE_GATE,
|
||||||
Material.SPRUCE_FENCE_GATE,
|
Material.JUNGLE_FENCE_GATE, Material.DARK_OAK_FENCE_GATE, Material.MANGROVE_FENCE_GATE,
|
||||||
Material.BIRCH_FENCE_GATE,
|
Material.ACACIA_FENCE_GATE, Material.DISPENSER, Material.NOTE_BLOCK, Material.CHEST, Material.FURNACE,
|
||||||
Material.JUNGLE_FENCE_GATE,
|
Material.LEVER, Material.REPEATER, Material.MANGROVE_TRAPDOOR, Material.ACACIA_TRAPDOOR,
|
||||||
Material.DARK_OAK_FENCE_GATE,
|
Material.BIRCH_TRAPDOOR, Material.DARK_OAK_TRAPDOOR, Material.JUNGLE_TRAPDOOR, Material.SPRUCE_TRAPDOOR,
|
||||||
Material.MANGROVE_FENCE_GATE,
|
Material.OAK_TRAPDOOR, Material.OAK_FENCE_GATE, Material.BREWING_STAND, Material.ANVIL,
|
||||||
Material.ACACIA_FENCE_GATE,
|
Material.CHIPPED_ANVIL, Material.DAMAGED_ANVIL, Material.ENDER_CHEST, Material.TRAPPED_CHEST,
|
||||||
Material.DISPENSER,
|
Material.COMPARATOR, Material.HOPPER, Material.DROPPER, Material.SHULKER_BOX,
|
||||||
Material.NOTE_BLOCK,
|
Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX,
|
||||||
Material.CHEST,
|
Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX,
|
||||||
Material.FURNACE,
|
Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX,
|
||||||
Material.LEVER,
|
Material.ORANGE_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX,
|
||||||
Material.REPEATER,
|
Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX, Material.WHITE_SHULKER_BOX,
|
||||||
Material.MANGROVE_TRAPDOOR,
|
Material.YELLOW_SHULKER_BOX, Material.BARREL, Material.BLAST_FURNACE, Material.GRINDSTONE,
|
||||||
Material.ACACIA_TRAPDOOR,
|
Material.LOOM, Material.SMOKER, Material.CRAFTING_TABLE, Material.CARTOGRAPHY_TABLE,
|
||||||
Material.BIRCH_TRAPDOOR,
|
Material.ENCHANTING_TABLE, Material.SMITHING_TABLE, Material.STONECUTTER, Material.CRIMSON_FENCE_GATE,
|
||||||
Material.DARK_OAK_TRAPDOOR,
|
Material.WARPED_FENCE_GATE, Material.CRIMSON_TRAPDOOR, Material.WARPED_TRAPDOOR));
|
||||||
Material.JUNGLE_TRAPDOOR,
|
BlockGroup.SAFE_INTERACT_BLOCKS = new HashSet<>(Arrays.asList(Material.LEVER, Material.MANGROVE_TRAPDOOR,
|
||||||
Material.SPRUCE_TRAPDOOR,
|
Material.ACACIA_TRAPDOOR, Material.BIRCH_TRAPDOOR, Material.DARK_OAK_TRAPDOOR, Material.JUNGLE_TRAPDOOR,
|
||||||
Material.OAK_TRAPDOOR,
|
Material.SPRUCE_TRAPDOOR, Material.OAK_TRAPDOOR, Material.OAK_FENCE_GATE, Material.SPRUCE_FENCE_GATE,
|
||||||
Material.OAK_FENCE_GATE,
|
Material.BIRCH_FENCE_GATE, Material.JUNGLE_FENCE_GATE, Material.DARK_OAK_FENCE_GATE,
|
||||||
Material.BREWING_STAND,
|
Material.MANGROVE_FENCE_GATE, Material.ACACIA_FENCE_GATE, Material.CRIMSON_FENCE_GATE,
|
||||||
Material.ANVIL,
|
Material.WARPED_FENCE_GATE, Material.CRIMSON_TRAPDOOR, Material.WARPED_TRAPDOOR));
|
||||||
Material.CHIPPED_ANVIL,
|
BlockGroup.NON_ATTACHABLE = new HashSet<>(Arrays.asList(Material.AIR, Material.CAVE_AIR, Material.BARRIER,
|
||||||
Material.DAMAGED_ANVIL,
|
Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH,
|
||||||
Material.ENDER_CHEST,
|
Material.OAK_SAPLING, Material.SPRUCE_SAPLING, Material.BIRCH_SAPLING, Material.JUNGLE_SAPLING,
|
||||||
Material.TRAPPED_CHEST,
|
Material.MANGROVE_PROPAGULE, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING, Material.WATER,
|
||||||
Material.COMPARATOR,
|
Material.LAVA, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FERN, Material.DEAD_BUSH,
|
||||||
Material.HOPPER,
|
Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET,
|
||||||
Material.DROPPER,
|
Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP,
|
||||||
Material.SHULKER_BOX,
|
Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.TORCH,
|
||||||
Material.BLACK_SHULKER_BOX,
|
Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.LADDER, Material.RAIL, Material.LEVER,
|
||||||
Material.BLUE_SHULKER_BOX,
|
Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.SNOW, Material.SUGAR_CANE,
|
||||||
Material.BROWN_SHULKER_BOX,
|
Material.NETHER_PORTAL, Material.REPEATER, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT,
|
||||||
Material.CYAN_SHULKER_BOX,
|
Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.LIGHT, Material.SMALL_DRIPLEAF,
|
||||||
Material.GRAY_SHULKER_BOX,
|
Material.BIG_DRIPLEAF, Material.BIG_DRIPLEAF_STEM, Material.GLOW_LICHEN, Material.HANGING_ROOTS));
|
||||||
Material.GREEN_SHULKER_BOX,
|
|
||||||
Material.LIGHT_BLUE_SHULKER_BOX,
|
|
||||||
Material.LIME_SHULKER_BOX,
|
|
||||||
Material.MAGENTA_SHULKER_BOX,
|
|
||||||
Material.ORANGE_SHULKER_BOX,
|
|
||||||
Material.PINK_SHULKER_BOX,
|
|
||||||
Material.PURPLE_SHULKER_BOX,
|
|
||||||
Material.RED_SHULKER_BOX,
|
|
||||||
Material.LIGHT_GRAY_SHULKER_BOX,
|
|
||||||
Material.WHITE_SHULKER_BOX,
|
|
||||||
Material.YELLOW_SHULKER_BOX,
|
|
||||||
Material.BARREL,
|
|
||||||
Material.BLAST_FURNACE,
|
|
||||||
Material.GRINDSTONE,
|
|
||||||
Material.LOOM,
|
|
||||||
Material.SMOKER,
|
|
||||||
Material.CRAFTING_TABLE,
|
|
||||||
Material.CARTOGRAPHY_TABLE,
|
|
||||||
Material.ENCHANTING_TABLE,
|
|
||||||
Material.SMITHING_TABLE,
|
|
||||||
Material.STONECUTTER,
|
|
||||||
Material.CRIMSON_FENCE_GATE,
|
|
||||||
Material.WARPED_FENCE_GATE,
|
|
||||||
Material.CRIMSON_TRAPDOOR,
|
|
||||||
Material.WARPED_TRAPDOOR));
|
|
||||||
BlockGroup.SAFE_INTERACT_BLOCKS = new HashSet<>(Arrays.asList(
|
|
||||||
Material.LEVER,
|
|
||||||
Material.MANGROVE_TRAPDOOR,
|
|
||||||
Material.ACACIA_TRAPDOOR,
|
|
||||||
Material.BIRCH_TRAPDOOR,
|
|
||||||
Material.DARK_OAK_TRAPDOOR,
|
|
||||||
Material.JUNGLE_TRAPDOOR,
|
|
||||||
Material.SPRUCE_TRAPDOOR,
|
|
||||||
Material.OAK_TRAPDOOR,
|
|
||||||
Material.OAK_FENCE_GATE,
|
|
||||||
Material.SPRUCE_FENCE_GATE,
|
|
||||||
Material.BIRCH_FENCE_GATE,
|
|
||||||
Material.JUNGLE_FENCE_GATE,
|
|
||||||
Material.DARK_OAK_FENCE_GATE,
|
|
||||||
Material.MANGROVE_FENCE_GATE,
|
|
||||||
Material.ACACIA_FENCE_GATE,
|
|
||||||
Material.CRIMSON_FENCE_GATE,
|
|
||||||
Material.WARPED_FENCE_GATE,
|
|
||||||
Material.CRIMSON_TRAPDOOR,
|
|
||||||
Material.WARPED_TRAPDOOR));
|
|
||||||
BlockGroup.NON_ATTACHABLE = new HashSet<>(Arrays.asList(
|
|
||||||
Material.AIR,
|
|
||||||
Material.CAVE_AIR,
|
|
||||||
Material.BARRIER,
|
|
||||||
Material.CORNFLOWER,
|
|
||||||
Material.LILY_OF_THE_VALLEY,
|
|
||||||
Material.WITHER_ROSE,
|
|
||||||
Material.SWEET_BERRY_BUSH,
|
|
||||||
Material.OAK_SAPLING,
|
|
||||||
Material.SPRUCE_SAPLING,
|
|
||||||
Material.BIRCH_SAPLING,
|
|
||||||
Material.JUNGLE_SAPLING,
|
|
||||||
Material.MANGROVE_PROPAGULE,
|
|
||||||
Material.ACACIA_SAPLING,
|
|
||||||
Material.DARK_OAK_SAPLING,
|
|
||||||
Material.WATER,
|
|
||||||
Material.LAVA,
|
|
||||||
Material.POWERED_RAIL,
|
|
||||||
Material.DETECTOR_RAIL,
|
|
||||||
Material.FERN,
|
|
||||||
Material.DEAD_BUSH,
|
|
||||||
Material.DANDELION,
|
|
||||||
Material.POPPY,
|
|
||||||
Material.BLUE_ORCHID,
|
|
||||||
Material.ALLIUM,
|
|
||||||
Material.AZURE_BLUET,
|
|
||||||
Material.RED_TULIP,
|
|
||||||
Material.ORANGE_TULIP,
|
|
||||||
Material.WHITE_TULIP,
|
|
||||||
Material.PINK_TULIP,
|
|
||||||
Material.OXEYE_DAISY,
|
|
||||||
Material.BROWN_MUSHROOM,
|
|
||||||
Material.RED_MUSHROOM,
|
|
||||||
Material.TORCH,
|
|
||||||
Material.WALL_TORCH,
|
|
||||||
Material.REDSTONE_WIRE,
|
|
||||||
Material.LADDER,
|
|
||||||
Material.RAIL,
|
|
||||||
Material.LEVER,
|
|
||||||
Material.REDSTONE_TORCH,
|
|
||||||
Material.REDSTONE_WALL_TORCH,
|
|
||||||
Material.SNOW,
|
|
||||||
Material.SUGAR_CANE,
|
|
||||||
Material.NETHER_PORTAL,
|
|
||||||
Material.REPEATER,
|
|
||||||
Material.KELP,
|
|
||||||
Material.CHORUS_FLOWER,
|
|
||||||
Material.CHORUS_PLANT,
|
|
||||||
Material.SOUL_TORCH,
|
|
||||||
Material.SOUL_WALL_TORCH,
|
|
||||||
Material.LIGHT,
|
|
||||||
Material.SMALL_DRIPLEAF,
|
|
||||||
Material.BIG_DRIPLEAF,
|
|
||||||
Material.BIG_DRIPLEAF_STEM,
|
|
||||||
Material.GLOW_LICHEN,
|
|
||||||
Material.HANGING_ROOTS));
|
|
||||||
BlockGroup.SCULK = new HashSet<>(
|
BlockGroup.SCULK = new HashSet<>(
|
||||||
Arrays.asList(Material.SCULK, Material.SCULK_VEIN, Material.SCULK_SENSOR, Material.SCULK_SHRIEKER));
|
Arrays.asList(Material.SCULK, Material.SCULK_VEIN, Material.SCULK_SENSOR, Material.SCULK_SHRIEKER));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getEntityMeta(LivingEntity entity, List<Object> info) {
|
public boolean getEntityMeta(LivingEntity entity, List<Object> info) {
|
||||||
|
|
||||||
if (entity instanceof Frog) {
|
if (entity instanceof Frog) {
|
||||||
|
|
||||||
Frog frog = (Frog) entity;
|
Frog frog = (Frog) entity;
|
||||||
info.add(BukkitAdapter.ADAPTER.getRegistryKey(frog.getVariant()));
|
info.add(BukkitAdapter.ADAPTER.getRegistryKey(frog.getVariant()));
|
||||||
|
|
||||||
} else if (entity instanceof Tadpole) {
|
} else if (entity instanceof Tadpole) {
|
||||||
|
|
||||||
Tadpole tadpole = (Tadpole) entity;
|
Tadpole tadpole = (Tadpole) entity;
|
||||||
info.add(tadpole.getAge());
|
info.add(tadpole.getAge());
|
||||||
|
|
||||||
} else if (entity instanceof Goat) {
|
} else if (entity instanceof Goat) {
|
||||||
|
|
||||||
Goat goat = (Goat) entity;
|
Goat goat = (Goat) entity;
|
||||||
info.add(goat.isScreaming());
|
info.add(goat.isScreaming());
|
||||||
info.add(goat.hasLeftHorn());
|
info.add(goat.hasLeftHorn());
|
||||||
info.add(goat.hasRightHorn());
|
info.add(goat.hasRightHorn());
|
||||||
|
|
||||||
} else if (super.getEntityMeta(entity, info)) {
|
} else if (super.getEntityMeta(entity, info)) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setEntityMeta(Entity entity, Object value, int count) {
|
public boolean setEntityMeta(Entity entity, Object value, int count) {
|
||||||
|
|
||||||
if (entity instanceof Frog) {
|
if (entity instanceof Frog) {
|
||||||
|
|
||||||
Frog frog = (Frog) entity;
|
Frog frog = (Frog) entity;
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
|
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
|
|
||||||
value = BukkitAdapter.ADAPTER.getRegistryValue((String) value, Frog.Variant.class);
|
value = BukkitAdapter.ADAPTER.getRegistryValue((String) value, Frog.Variant.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Frog.Variant set = (Frog.Variant) value;
|
Frog.Variant set = (Frog.Variant) value;
|
||||||
frog.setVariant(set);
|
frog.setVariant(set);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (entity instanceof Tadpole) {
|
} else if (entity instanceof Tadpole) {
|
||||||
|
|
||||||
Tadpole tadpole = (Tadpole) entity;
|
Tadpole tadpole = (Tadpole) entity;
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
|
|
||||||
int set = (int) value;
|
int set = (int) value;
|
||||||
tadpole.setAge(set);
|
tadpole.setAge(set);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (entity instanceof Goat) {
|
} else if (entity instanceof Goat) {
|
||||||
|
|
||||||
Goat goat = (Goat) entity;
|
Goat goat = (Goat) entity;
|
||||||
boolean set = (Boolean) value;
|
boolean set = (Boolean) value;
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
|
|
||||||
goat.setScreaming(set);
|
goat.setScreaming(set);
|
||||||
|
|
||||||
} else if (count == 1) {
|
} else if (count == 1) {
|
||||||
|
|
||||||
goat.setLeftHorn(set);
|
goat.setLeftHorn(set);
|
||||||
|
|
||||||
} else if (count == 2) {
|
} else if (count == 2) {
|
||||||
|
|
||||||
goat.setRightHorn(set);
|
goat.setRightHorn(set);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (super.setEntityMeta(entity, value, count)) {
|
} else if (super.setEntityMeta(entity, value, count)) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,9 +11,13 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class ApplyCommand {
|
public class ApplyCommand {
|
||||||
|
|
||||||
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
|
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
||||||
|
|
||||||
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
||||||
long startTime = (Long) list.get(0);
|
long startTime = (Long) list.get(0);
|
||||||
long endTime = (Long) list.get(1);
|
long endTime = (Long) list.get(1);
|
||||||
@@ -21,28 +25,41 @@ public class ApplyCommand {
|
|||||||
Location location = (Location) list.get(3);
|
Location location = (Location) list.get(3);
|
||||||
boolean valid = false;
|
boolean valid = false;
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
|
||||||
if (args[i].equals("#preview")) {
|
if (args[i].equals("#preview")) {
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
args[i] = args[i].replaceAll("#preview", "");
|
args[i] = args[i].replaceAll("#preview", "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.NO_ROLLBACK, Selector.FIRST));
|
||||||
+ Phrase.build(Phrase.NO_ROLLBACK, Selector.FIRST));
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ConfigHandler.lastRollback.remove(user.getName());
|
ConfigHandler.lastRollback.remove(user.getName());
|
||||||
RollbackRestoreCommand.runCommand(user, command, permission, args, location, startTime, endTime);
|
RollbackRestoreCommand.runCommand(user, command, permission, args, location, startTime, endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.NO_ROLLBACK, Selector.FIRST));
|
||||||
+ Phrase.build(Phrase.NO_ROLLBACK, Selector.FIRST));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,9 +11,13 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class CancelCommand {
|
public class CancelCommand {
|
||||||
|
|
||||||
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
|
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
||||||
|
|
||||||
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
||||||
long startTime = (Long) list.get(0);
|
long startTime = (Long) list.get(0);
|
||||||
long endTime = (Long) list.get(1);
|
long endTime = (Long) list.get(1);
|
||||||
@@ -21,28 +25,41 @@ public class CancelCommand {
|
|||||||
Location location = (Location) list.get(3);
|
Location location = (Location) list.get(3);
|
||||||
boolean valid = false;
|
boolean valid = false;
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
|
||||||
if (args[i].equals("#preview")) {
|
if (args[i].equals("#preview")) {
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
args[i] = args[i].replaceAll("#preview", "#preview_cancel");
|
args[i] = args[i].replaceAll("#preview", "#preview_cancel");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.NO_ROLLBACK, Selector.FIRST));
|
||||||
+ Phrase.build(Phrase.NO_ROLLBACK, Selector.FIRST));
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ConfigHandler.lastRollback.remove(user.getName());
|
ConfigHandler.lastRollback.remove(user.getName());
|
||||||
RollbackRestoreCommand.runCommand(user, command, permission, args, location, startTime, endTime);
|
RollbackRestoreCommand.runCommand(user, command, permission, args, location, startTime, endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.NO_ROLLBACK, Selector.FIRST));
|
||||||
+ Phrase.build(Phrase.NO_ROLLBACK, Selector.FIRST));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -12,74 +12,94 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||||||
public class ConsumerCommand {
|
public class ConsumerCommand {
|
||||||
|
|
||||||
private ConsumerCommand() {
|
private ConsumerCommand() {
|
||||||
|
|
||||||
throw new IllegalStateException("Command class");
|
throw new IllegalStateException("Command class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void runCommand(final CommandSender player, boolean permission, String[] args) {
|
protected static void runCommand(final CommandSender player, boolean permission, String[] args) {
|
||||||
|
|
||||||
if (!permission) {
|
if (!permission) {
|
||||||
Chat.sendMessage(
|
|
||||||
player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
Chat.sendMessage(player,
|
||||||
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(player instanceof ConsoleCommandSender)) {
|
if (!(player instanceof ConsoleCommandSender)) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_CONSOLE));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_CONSOLE));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.converterRunning) {
|
if (ConfigHandler.converterRunning) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.purgeRunning) {
|
if (ConfigHandler.purgeRunning) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
|
|
||||||
String action = args[1].toLowerCase(Locale.ROOT);
|
String action = args[1].toLowerCase(Locale.ROOT);
|
||||||
boolean pauseCommand = (action.equals("pause") || action.equals("disable") || action.equals("stop"));
|
boolean pauseCommand = (action.equals("pause") || action.equals("disable") || action.equals("stop"));
|
||||||
boolean resumeCommand = (action.equals("resume") || action.equals("enable") || action.equals("start"));
|
boolean resumeCommand = (action.equals("resume") || action.equals("enable") || action.equals("start"));
|
||||||
|
|
||||||
if (pauseCommand || resumeCommand) {
|
if (pauseCommand || resumeCommand) {
|
||||||
|
|
||||||
if (ConfigHandler.pauseConsumer) {
|
if (ConfigHandler.pauseConsumer) {
|
||||||
|
|
||||||
if (pauseCommand) {
|
if (pauseCommand) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.CONSUMER_ERROR, Selector.FIRST)); // already paused
|
||||||
+ Phrase.build(Phrase.CONSUMER_ERROR, Selector.FIRST)); // already paused
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ConfigHandler.pauseConsumer = false;
|
ConfigHandler.pauseConsumer = false;
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
player,
|
+ Phrase.build(Phrase.CONSUMER_TOGGLED, Selector.SECOND)); // now started
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.CONSUMER_TOGGLED, Selector.SECOND)); // now started
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (resumeCommand) {
|
if (resumeCommand) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.CONSUMER_ERROR, Selector.SECOND)); // already running
|
||||||
+ Phrase.build(Phrase.CONSUMER_ERROR, Selector.SECOND)); // already running
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ConfigHandler.pauseConsumer = true;
|
ConfigHandler.pauseConsumer = true;
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
player,
|
+ Phrase.build(Phrase.CONSUMER_TOGGLED, Selector.FIRST)); // now paused
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.CONSUMER_TOGGLED, Selector.FIRST)); // now paused
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
player,
|
+ Phrase.build(Phrase.MISSING_PARAMETERS, Color.WHITE, "/co consumer <pause|resume>"));
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.MISSING_PARAMETERS, Color.WHITE, "/co consumer <pause|resume>"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,24 +8,28 @@ import net.coreprotect.utility.Color;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class HelpCommand {
|
public class HelpCommand {
|
||||||
|
|
||||||
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
||||||
|
|
||||||
int resultc = args.length;
|
int resultc = args.length;
|
||||||
if (permission) {
|
if (permission) {
|
||||||
|
|
||||||
if (resultc > 1) {
|
if (resultc > 1) {
|
||||||
|
|
||||||
String helpcommand_original = args[1];
|
String helpcommand_original = args[1];
|
||||||
String helpcommand = args[1].toLowerCase(Locale.ROOT);
|
String helpcommand = args[1].toLowerCase(Locale.ROOT);
|
||||||
helpcommand = helpcommand.replaceAll("[^a-zA-Z]", "");
|
helpcommand = helpcommand.replaceAll("[^a-zA-Z]", "");
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA
|
||||||
player,
|
+ Phrase.build(Phrase.HELP_HEADER, "CoreProtect") + Color.WHITE + " -----");
|
||||||
Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.HELP_HEADER, "CoreProtect")
|
|
||||||
+ Color.WHITE + " -----");
|
|
||||||
if (helpcommand.equals("help")) {
|
if (helpcommand.equals("help")) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "/co help " + Color.WHITE + "- " + Phrase.build(Phrase.HELP_LIST));
|
Color.DARK_AQUA + "/co help " + Color.WHITE + "- " + Phrase.build(Phrase.HELP_LIST));
|
||||||
} else if (helpcommand.equals("inspect")
|
|
||||||
|| helpcommand.equals("inspector")
|
} else if (helpcommand.equals("inspect") || helpcommand.equals("inspector")
|
||||||
|| helpcommand.equals("in")) {
|
|| helpcommand.equals("in"))
|
||||||
|
{
|
||||||
|
|
||||||
Chat.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.HELP_INSPECT_1));
|
Chat.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.HELP_INSPECT_1));
|
||||||
Chat.sendMessage(player, "* " + Phrase.build(Phrase.HELP_INSPECT_2));
|
Chat.sendMessage(player, "* " + Phrase.build(Phrase.HELP_INSPECT_2));
|
||||||
Chat.sendMessage(player, "* " + Phrase.build(Phrase.HELP_INSPECT_3));
|
Chat.sendMessage(player, "* " + Phrase.build(Phrase.HELP_INSPECT_3));
|
||||||
@@ -33,258 +37,188 @@ public class HelpCommand {
|
|||||||
Chat.sendMessage(player, "* " + Phrase.build(Phrase.HELP_INSPECT_5));
|
Chat.sendMessage(player, "* " + Phrase.build(Phrase.HELP_INSPECT_5));
|
||||||
Chat.sendMessage(player, "* " + Phrase.build(Phrase.HELP_INSPECT_6));
|
Chat.sendMessage(player, "* " + Phrase.build(Phrase.HELP_INSPECT_6));
|
||||||
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_INSPECT_7));
|
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_INSPECT_7));
|
||||||
} else if (helpcommand.equals("params")
|
|
||||||
|| helpcommand.equals("param")
|
} else if (helpcommand.equals("params") || helpcommand.equals("param")
|
||||||
|| helpcommand.equals("parameters")
|
|| helpcommand.equals("parameters") || helpcommand.equals("parameter"))
|
||||||
|| helpcommand.equals("parameter")) {
|
{
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co lookup " + Color.GREY + "<params> " + Color.WHITE
|
||||||
Color.DARK_AQUA + "/co lookup " + Color.GREY + "<params> " + Color.WHITE + "- "
|
+ "- " + Phrase.build(Phrase.HELP_PARAMS_1, Selector.FIRST));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_1, Selector.FIRST));
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "u:<users> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_PARAMS_2, Selector.FIRST));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "t:<time> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "u:<users> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_PARAMS_3, Selector.FIRST));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_2, Selector.FIRST));
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "r:<radius> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_PARAMS_4, Selector.FIRST));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "a:<action> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "t:<time> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_PARAMS_5, Selector.FIRST));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_3, Selector.FIRST));
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "i:<include> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_PARAMS_6, Selector.FIRST));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "e:<exclude> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "r:<radius> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_PARAMS_7, Selector.FIRST));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_4, Selector.FIRST));
|
Chat.sendMessage(player,
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "a:<action> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_5, Selector.FIRST));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "i:<include> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_6, Selector.FIRST));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "e:<exclude> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_7, Selector.FIRST));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_PARAMETER, "/co help <param>"));
|
Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_PARAMETER, "/co help <param>"));
|
||||||
} else if (helpcommand.equals("rollback")
|
|
||||||
|| helpcommand.equals("rollbacks")
|
} else if (helpcommand.equals("rollback") || helpcommand.equals("rollbacks") || helpcommand.equals("rb")
|
||||||
|| helpcommand.equals("rb")
|
|| helpcommand.equals("ro"))
|
||||||
|| helpcommand.equals("ro")) {
|
{
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co rollback " + Color.GREY + "<params> " + Color.WHITE
|
||||||
Color.DARK_AQUA + "/co rollback " + Color.GREY + "<params> " + Color.WHITE + "- "
|
+ "- " + Phrase.build(Phrase.HELP_PARAMS_1, Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_1, Selector.SECOND));
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "u:<users> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_PARAMS_2, Selector.SECOND));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "t:<time> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "u:<users> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_PARAMS_3, Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_2, Selector.SECOND));
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "r:<radius> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_PARAMS_4, Selector.SECOND));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "a:<action> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "t:<time> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_PARAMS_5, Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_3, Selector.SECOND));
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "i:<include> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_PARAMS_6, Selector.SECOND));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "e:<exclude> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "r:<radius> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_PARAMS_7, Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_4, Selector.SECOND));
|
Chat.sendMessage(player,
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "a:<action> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_5, Selector.SECOND));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "i:<include> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_6, Selector.SECOND));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "e:<exclude> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_7, Selector.SECOND));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_PARAMETER, "/co help <param>"));
|
Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_PARAMETER, "/co help <param>"));
|
||||||
} else if (helpcommand.equals("restore")
|
|
||||||
|| helpcommand.equals("restores")
|
} else if (helpcommand.equals("restore") || helpcommand.equals("restores") || helpcommand.equals("re")
|
||||||
|| helpcommand.equals("re")
|
|| helpcommand.equals("rs"))
|
||||||
|| helpcommand.equals("rs")) {
|
{
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co restore " + Color.GREY + "<params> " + Color.WHITE
|
||||||
Color.DARK_AQUA + "/co restore " + Color.GREY + "<params> " + Color.WHITE + "- "
|
+ "- " + Phrase.build(Phrase.HELP_PARAMS_1, Selector.THIRD));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_1, Selector.THIRD));
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "u:<users> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_PARAMS_2, Selector.THIRD));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "t:<time> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "u:<users> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_PARAMS_3, Selector.THIRD));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_2, Selector.THIRD));
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "r:<radius> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_PARAMS_4, Selector.THIRD));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "a:<action> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "t:<time> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_PARAMS_5, Selector.THIRD));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_3, Selector.THIRD));
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "i:<include> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_PARAMS_6, Selector.THIRD));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "| " + Color.GREY + "e:<exclude> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "r:<radius> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_PARAMS_7, Selector.THIRD));
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_4, Selector.THIRD));
|
Chat.sendMessage(player,
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "a:<action> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_5, Selector.THIRD));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "i:<include> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_6, Selector.THIRD));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "| " + Color.GREY + "e:<exclude> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_PARAMS_7, Selector.THIRD));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_PARAMETER, "/co help <param>"));
|
Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_PARAMETER, "/co help <param>"));
|
||||||
|
|
||||||
} else if (helpcommand.equals("lookup") || helpcommand.equals("lookups") || helpcommand.equals("l")) {
|
} else if (helpcommand.equals("lookup") || helpcommand.equals("lookups") || helpcommand.equals("l")) {
|
||||||
|
|
||||||
Chat.sendMessage(player, Color.DARK_AQUA + "/co lookup <params>");
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co lookup <params>");
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co l <params> " + Color.WHITE + "- "
|
||||||
player,
|
+ Phrase.build(Phrase.HELP_LOOKUP_1));
|
||||||
Color.DARK_AQUA + "/co l <params> " + Color.WHITE + "- "
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co lookup <page> " + Color.WHITE + "- "
|
||||||
+ Phrase.build(Phrase.HELP_LOOKUP_1));
|
+ Phrase.build(Phrase.HELP_LOOKUP_2));
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player,
|
||||||
player,
|
Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_PARAMETER, "/co help params"));
|
||||||
Color.DARK_AQUA + "/co lookup <page> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_LOOKUP_2));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_PARAMETER, "/co help params"));
|
|
||||||
} else if (helpcommand.equals("purge") || helpcommand.equals("purges")) {
|
} else if (helpcommand.equals("purge") || helpcommand.equals("purges")) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co purge t:<time> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "/co purge t:<time> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_PURGE_1));
|
||||||
+ Phrase.build(Phrase.HELP_PURGE_1));
|
Chat.sendMessage(player,
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.GREY + Color.ITALIC + "" + Phrase.build(Phrase.HELP_PURGE_2, "/co purge t:30d"));
|
Color.GREY + Color.ITALIC + "" + Phrase.build(Phrase.HELP_PURGE_2, "/co purge t:30d"));
|
||||||
|
|
||||||
} else if (helpcommand.equals("reload")) {
|
} else if (helpcommand.equals("reload")) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co reload " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "/co reload " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_RELOAD_COMMAND));
|
||||||
+ Phrase.build(Phrase.HELP_RELOAD_COMMAND));
|
|
||||||
} else if (helpcommand.equals("status")) {
|
} else if (helpcommand.equals("status")) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "/co status " + Color.WHITE + "- " + Phrase.build(Phrase.HELP_STATUS));
|
Color.DARK_AQUA + "/co status " + Color.WHITE + "- " + Phrase.build(Phrase.HELP_STATUS));
|
||||||
|
|
||||||
} else if (helpcommand.equals("teleport")) {
|
} else if (helpcommand.equals("teleport")) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co teleport <world> <x> <y> <z> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "/co teleport <world> <x> <y> <z> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_TELEPORT));
|
||||||
+ Phrase.build(Phrase.HELP_TELEPORT));
|
|
||||||
} else if (helpcommand.equals("u")
|
} else if (helpcommand.equals("u") || helpcommand.equals("user") || helpcommand.equals("users")
|
||||||
|| helpcommand.equals("user")
|
|| helpcommand.equals("uuser") || helpcommand.equals("uusers"))
|
||||||
|| helpcommand.equals("users")
|
{
|
||||||
|| helpcommand.equals("uuser")
|
|
||||||
|| helpcommand.equals("uusers")) {
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co lookup u:<users> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_USER_1));
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "/co lookup u:<users> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_USER_1));
|
|
||||||
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_USER_2));
|
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_USER_2));
|
||||||
|
|
||||||
} else if (helpcommand.equals("t") || helpcommand.equals("time") || helpcommand.equals("ttime")) {
|
} else if (helpcommand.equals("t") || helpcommand.equals("time") || helpcommand.equals("ttime")) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co lookup t:<time> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "/co lookup t:<time> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_TIME_1));
|
||||||
+ Phrase.build(Phrase.HELP_TIME_1));
|
|
||||||
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_TIME_2));
|
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_TIME_2));
|
||||||
|
|
||||||
} else if (helpcommand.equals("r") || helpcommand.equals("radius") || helpcommand.equals("rradius")) {
|
} else if (helpcommand.equals("r") || helpcommand.equals("radius") || helpcommand.equals("rradius")) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co lookup r:<radius> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "/co lookup r:<radius> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_RADIUS_1));
|
||||||
+ Phrase.build(Phrase.HELP_RADIUS_1));
|
|
||||||
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_RADIUS_2));
|
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_RADIUS_2));
|
||||||
} else if (helpcommand.equals("a")
|
|
||||||
|| helpcommand.equals("action")
|
} else if (helpcommand.equals("a") || helpcommand.equals("action") || helpcommand.equals("actions")
|
||||||
|| helpcommand.equals("actions")
|
|| helpcommand.equals("aaction"))
|
||||||
|| helpcommand.equals("aaction")) {
|
{
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co lookup a:<action> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "/co lookup a:<action> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_ACTION_1));
|
||||||
+ Phrase.build(Phrase.HELP_ACTION_1));
|
|
||||||
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_ACTION_2));
|
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_ACTION_2));
|
||||||
} else if (helpcommand.equals("i")
|
|
||||||
|| helpcommand.equals("include")
|
} else if (helpcommand.equals("i") || helpcommand.equals("include") || helpcommand.equals("iinclude")
|
||||||
|| helpcommand.equals("iinclude")
|
|| helpcommand.equals("b") || helpcommand.equals("block") || helpcommand.equals("blocks")
|
||||||
|| helpcommand.equals("b")
|
|| helpcommand.equals("bblock") || helpcommand.equals("bblocks"))
|
||||||
|| helpcommand.equals("block")
|
{
|
||||||
|| helpcommand.equals("blocks")
|
|
||||||
|| helpcommand.equals("bblock")
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co lookup i:<include> " + Color.WHITE + "- "
|
||||||
|| helpcommand.equals("bblocks")) {
|
+ Phrase.build(Phrase.HELP_INCLUDE_1));
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "/co lookup i:<include> " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_INCLUDE_1));
|
|
||||||
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_INCLUDE_2));
|
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_INCLUDE_2));
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player, Color.GREY + Color.ITALIC
|
||||||
player,
|
+ Phrase.build(Phrase.LINK_WIKI_BLOCK, "https://coreprotect.net/wiki-blocks"));
|
||||||
Color.GREY
|
Chat.sendMessage(player, Color.GREY + Color.ITALIC
|
||||||
+ Color.ITALIC
|
+ Phrase.build(Phrase.LINK_WIKI_ENTITY, "https://coreprotect.net/wiki-entities"));
|
||||||
+ Phrase.build(Phrase.LINK_WIKI_BLOCK, "https://coreprotect.net/wiki-blocks"));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.GREY
|
|
||||||
+ Color.ITALIC
|
|
||||||
+ Phrase.build(Phrase.LINK_WIKI_ENTITY, "https://coreprotect.net/wiki-entities"));
|
|
||||||
} else if (helpcommand.equals("e") || helpcommand.equals("exclude") || helpcommand.equals("eexclude")) {
|
} else if (helpcommand.equals("e") || helpcommand.equals("exclude") || helpcommand.equals("eexclude")) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co lookup e:<exclude> " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "/co lookup e:<exclude> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_EXCLUDE_1));
|
||||||
+ Phrase.build(Phrase.HELP_EXCLUDE_1));
|
|
||||||
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_EXCLUDE_2));
|
Chat.sendMessage(player, Color.GREY + Color.ITALIC + Phrase.build(Phrase.HELP_EXCLUDE_2));
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player, Color.GREY + Color.ITALIC
|
||||||
player,
|
+ Phrase.build(Phrase.LINK_WIKI_BLOCK, "https://coreprotect.net/wiki-blocks"));
|
||||||
Color.GREY
|
|
||||||
+ Color.ITALIC
|
|
||||||
+ Phrase.build(Phrase.LINK_WIKI_BLOCK, "https://coreprotect.net/wiki-blocks"));
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.WHITE
|
||||||
Color.WHITE
|
+ Phrase.build(Phrase.HELP_NO_INFO, Color.WHITE, "/co help " + helpcommand_original));
|
||||||
+ Phrase.build(
|
|
||||||
Phrase.HELP_NO_INFO, Color.WHITE, "/co help " + helpcommand_original));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA
|
||||||
Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.HELP_HEADER, "CoreProtect")
|
+ Phrase.build(Phrase.HELP_HEADER, "CoreProtect") + Color.WHITE + " -----");
|
||||||
+ Color.WHITE + " -----");
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co help " + Color.GREY + "<command> " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_COMMAND));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co " + Color.GREY + "inspect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "/co help " + Color.GREY + "<command> " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.HELP_INSPECT_COMMAND));
|
||||||
+ Phrase.build(Phrase.HELP_COMMAND));
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co " + Color.GREY + "rollback " + Color.DARK_AQUA
|
||||||
Chat.sendMessage(
|
+ "<params> " + Color.WHITE + "- " + Phrase.build(Phrase.HELP_ROLLBACK_COMMAND));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co " + Color.GREY + "restore " + Color.DARK_AQUA
|
||||||
Color.DARK_AQUA + "/co " + Color.GREY + "inspect " + Color.WHITE + "- "
|
+ "<params> " + Color.WHITE + "- " + Phrase.build(Phrase.HELP_RESTORE_COMMAND));
|
||||||
+ Phrase.build(Phrase.HELP_INSPECT_COMMAND));
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co " + Color.GREY + "lookup " + Color.DARK_AQUA
|
||||||
Chat.sendMessage(
|
+ "<params> " + Color.WHITE + "- " + Phrase.build(Phrase.HELP_LOOKUP_COMMAND));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co " + Color.GREY + "purge " + Color.DARK_AQUA
|
||||||
Color.DARK_AQUA + "/co " + Color.GREY + "rollback " + Color.DARK_AQUA + "<params> "
|
+ "<params> " + Color.WHITE + "- " + Phrase.build(Phrase.HELP_PURGE_COMMAND));
|
||||||
+ Color.WHITE + "- " + Phrase.build(Phrase.HELP_ROLLBACK_COMMAND));
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co " + Color.GREY + "reload " + Color.WHITE + "- "
|
||||||
Chat.sendMessage(
|
+ Phrase.build(Phrase.HELP_RELOAD_COMMAND));
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "/co " + Color.GREY + "status " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "/co " + Color.GREY + "restore " + Color.DARK_AQUA + "<params> " + Color.WHITE
|
+ Phrase.build(Phrase.HELP_STATUS_COMMAND));
|
||||||
+ "- " + Phrase.build(Phrase.HELP_RESTORE_COMMAND));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "/co " + Color.GREY + "lookup " + Color.DARK_AQUA + "<params> " + Color.WHITE
|
|
||||||
+ "- " + Phrase.build(Phrase.HELP_LOOKUP_COMMAND));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "/co " + Color.GREY + "purge " + Color.DARK_AQUA + "<params> " + Color.WHITE
|
|
||||||
+ "- " + Phrase.build(Phrase.HELP_PURGE_COMMAND));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "/co " + Color.GREY + "reload " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_RELOAD_COMMAND));
|
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "/co " + Color.GREY + "status " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.HELP_STATUS_COMMAND));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
Chat.sendMessage(player,
|
||||||
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,52 +8,68 @@ import net.coreprotect.utility.Color;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class InspectCommand {
|
public class InspectCommand {
|
||||||
|
|
||||||
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
||||||
|
|
||||||
if (permission) {
|
if (permission) {
|
||||||
|
|
||||||
int command = -1;
|
int command = -1;
|
||||||
ConfigHandler.inspecting.putIfAbsent(player.getName(), false);
|
ConfigHandler.inspecting.putIfAbsent(player.getName(), false);
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
|
|
||||||
String action = args[1];
|
String action = args[1];
|
||||||
if (action.equalsIgnoreCase("on")) {
|
if (action.equalsIgnoreCase("on")) {
|
||||||
|
|
||||||
command = 1;
|
command = 1;
|
||||||
|
|
||||||
} else if (action.equalsIgnoreCase("off")) {
|
} else if (action.equalsIgnoreCase("off")) {
|
||||||
|
|
||||||
command = 0;
|
command = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConfigHandler.inspecting.get(player.getName())) {
|
if (!ConfigHandler.inspecting.get(player.getName())) {
|
||||||
|
|
||||||
if (command == 0) {
|
if (command == 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.INSPECTOR_ERROR, Selector.SECOND)); // already disabled
|
||||||
+ Phrase.build(Phrase.INSPECTOR_ERROR, Selector.SECOND)); // already disabled
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.INSPECTOR_TOGGLED, Selector.FIRST)); // now enabled
|
||||||
+ Phrase.build(Phrase.INSPECTOR_TOGGLED, Selector.FIRST)); // now enabled
|
|
||||||
ConfigHandler.inspecting.put(player.getName(), true);
|
ConfigHandler.inspecting.put(player.getName(), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (command == 1) {
|
if (command == 1) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.INSPECTOR_ERROR, Selector.FIRST)); // already enabled
|
||||||
+ Phrase.build(Phrase.INSPECTOR_ERROR, Selector.FIRST)); // already enabled
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.INSPECTOR_TOGGLED, Selector.SECOND)); // now disabled
|
||||||
+ Phrase.build(Phrase.INSPECTOR_TOGGLED, Selector.SECOND)); // now disabled
|
|
||||||
ConfigHandler.inspecting.put(player.getName(), false);
|
ConfigHandler.inspecting.put(player.getName(), false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
Chat.sendMessage(player,
|
||||||
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -8,17 +8,27 @@ import net.coreprotect.utility.Color;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class NetworkDebugCommand {
|
public class NetworkDebugCommand {
|
||||||
|
|
||||||
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
||||||
|
|
||||||
if (!permission || !Config.getGlobal().NETWORK_DEBUG) {
|
if (!permission || !Config.getGlobal().NETWORK_DEBUG) {
|
||||||
Chat.sendMessage(
|
|
||||||
player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
Chat.sendMessage(player,
|
||||||
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
PluginChannelListener.getInstance().sendTest(player, args.length == 2 ? args[1] : "");
|
PluginChannelListener.getInstance().sendTest(player, args.length == 2 ? args[1] : "");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class PurgeCommand extends Consumer {
|
public class PurgeCommand extends Consumer {
|
||||||
|
|
||||||
protected static void runCommand(final CommandSender player, boolean permission, String[] args) {
|
protected static void runCommand(final CommandSender player, boolean permission, String[] args) {
|
||||||
|
|
||||||
int resultc = args.length;
|
int resultc = args.length;
|
||||||
Location location = CommandHandler.parseLocation(player, args);
|
Location location = CommandHandler.parseLocation(player, args);
|
||||||
final Integer[] argRadius = CommandHandler.parseRadius(args, player, location);
|
final Integer[] argRadius = CommandHandler.parseRadius(args, player, location);
|
||||||
@@ -45,71 +46,92 @@ public class PurgeCommand extends Consumer {
|
|||||||
long endTime = argTime[1] > 0 ? argTime[1] : argTime[0];
|
long endTime = argTime[1] > 0 ? argTime[1] : argTime[0];
|
||||||
|
|
||||||
if (argBlocks == null || argExclude == null || argExcludeUsers == null) {
|
if (argBlocks == null || argExclude == null || argExcludeUsers == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.converterRunning || ConfigHandler.migrationRunning) {
|
if (ConfigHandler.converterRunning || ConfigHandler.migrationRunning) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.purgeRunning) {
|
if (ConfigHandler.purgeRunning) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!permission) {
|
if (!permission) {
|
||||||
Chat.sendMessage(
|
|
||||||
player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
Chat.sendMessage(player,
|
||||||
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultc <= 1) {
|
if (resultc <= 1) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_PARAMETERS, "/co purge t:<time>"));
|
||||||
+ Phrase.build(Phrase.MISSING_PARAMETERS, "/co purge t:<time>"));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endTime <= 0) {
|
if (endTime <= 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_PARAMETERS, "/co purge t:<time>"));
|
||||||
+ Phrase.build(Phrase.MISSING_PARAMETERS, "/co purge t:<time>"));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argRadius != null) {
|
if (argRadius != null) {
|
||||||
|
|
||||||
Chat.sendMessage(player, new ChatMessage(Phrase.build(Phrase.INVALID_WORLD)).build());
|
Chat.sendMessage(player, new ChatMessage(Phrase.build(Phrase.INVALID_WORLD)).build());
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argWid == -1) {
|
if (argWid == -1) {
|
||||||
|
|
||||||
String worldName = CommandHandler.parseWorldName(args, false);
|
String worldName = CommandHandler.parseWorldName(args, false);
|
||||||
Chat.sendMessage(player, new ChatMessage(Phrase.build(Phrase.WORLD_NOT_FOUND, worldName)).build());
|
Chat.sendMessage(player, new ChatMessage(Phrase.build(Phrase.WORLD_NOT_FOUND, worldName)).build());
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player instanceof Player && endTime < 2592000) {
|
if (player instanceof Player && endTime < 2592000) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.PURGE_MINIMUM_TIME, "30", Selector.FIRST)); // 30 days
|
||||||
+ Phrase.build(Phrase.PURGE_MINIMUM_TIME, "30", Selector.FIRST)); // 30 days
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (endTime < 86400) {
|
} else if (endTime < 86400) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.PURGE_MINIMUM_TIME, "24", Selector.SECOND)); // 24 hours
|
||||||
+ Phrase.build(Phrase.PURGE_MINIMUM_TIME, "24", Selector.SECOND)); // 24 hours
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int action : argAction) {
|
for (int action : argAction) {
|
||||||
|
|
||||||
if (!supportedActions.contains(action)) {
|
if (!supportedActions.contains(action)) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ACTION_NOT_SUPPORTED));
|
||||||
+ Phrase.build(Phrase.ACTION_NOT_SUPPORTED));
|
// Functions.sendMessage(player, new ChatMessage("Please specify a valid purge
|
||||||
// Functions.sendMessage(player, new ChatMessage("Please specify a valid purge action.").build());
|
// action.").build());
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder restrict = new StringBuilder();
|
StringBuilder restrict = new StringBuilder();
|
||||||
@@ -121,67 +143,94 @@ public class PurgeCommand extends Consumer {
|
|||||||
int restrictCount = 0;
|
int restrictCount = 0;
|
||||||
|
|
||||||
if (argBlocks.size() > 0) {
|
if (argBlocks.size() > 0) {
|
||||||
|
|
||||||
StringBuilder includeListMaterial = new StringBuilder();
|
StringBuilder includeListMaterial = new StringBuilder();
|
||||||
StringBuilder includeListEntity = new StringBuilder();
|
StringBuilder includeListEntity = new StringBuilder();
|
||||||
|
|
||||||
for (Object restrictTarget : argBlocks) {
|
for (Object restrictTarget : argBlocks) {
|
||||||
|
|
||||||
String targetName = "";
|
String targetName = "";
|
||||||
|
|
||||||
if (restrictTarget instanceof Material) {
|
if (restrictTarget instanceof Material) {
|
||||||
|
|
||||||
targetName = ((Material) restrictTarget).name();
|
targetName = ((Material) restrictTarget).name();
|
||||||
if (includeListMaterial.length() == 0) {
|
if (includeListMaterial.length() == 0) {
|
||||||
|
|
||||||
includeListMaterial = includeListMaterial.append(Util.getBlockId(targetName, false));
|
includeListMaterial = includeListMaterial.append(Util.getBlockId(targetName, false));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
includeListMaterial.append(",").append(Util.getBlockId(targetName, false));
|
includeListMaterial.append(",").append(Util.getBlockId(targetName, false));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Include legacy IDs */
|
/* Include legacy IDs */
|
||||||
int legacyId = BukkitAdapter.ADAPTER.getLegacyBlockId((Material) restrictTarget);
|
int legacyId = BukkitAdapter.ADAPTER.getLegacyBlockId((Material) restrictTarget);
|
||||||
if (legacyId > 0) {
|
if (legacyId > 0) {
|
||||||
|
|
||||||
includeListMaterial.append(",").append(legacyId);
|
includeListMaterial.append(",").append(legacyId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
targetName = ((Material) restrictTarget).name().toLowerCase(Locale.ROOT);
|
targetName = ((Material) restrictTarget).name().toLowerCase(Locale.ROOT);
|
||||||
item = (!item ? !(((Material) restrictTarget).isBlock()) : item);
|
item = (!item ? !(((Material) restrictTarget).isBlock()) : item);
|
||||||
hasBlock = true;
|
hasBlock = true;
|
||||||
|
|
||||||
} else if (restrictTarget instanceof EntityType) {
|
} else if (restrictTarget instanceof EntityType) {
|
||||||
|
|
||||||
targetName = ((EntityType) restrictTarget).name();
|
targetName = ((EntityType) restrictTarget).name();
|
||||||
if (includeListEntity.length() == 0) {
|
if (includeListEntity.length() == 0) {
|
||||||
|
|
||||||
includeListEntity = includeListEntity.append(Util.getEntityId(targetName, false));
|
includeListEntity = includeListEntity.append(Util.getEntityId(targetName, false));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
includeListEntity.append(",").append(Util.getEntityId(targetName, false));
|
includeListEntity.append(",").append(Util.getEntityId(targetName, false));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
targetName = ((EntityType) restrictTarget).name().toLowerCase(Locale.ROOT);
|
targetName = ((EntityType) restrictTarget).name().toLowerCase(Locale.ROOT);
|
||||||
entity = true;
|
entity = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (restrictCount == 0) {
|
if (restrictCount == 0) {
|
||||||
|
|
||||||
restrict = restrict.append("" + targetName + "");
|
restrict = restrict.append("" + targetName + "");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
restrict.append(", ").append(targetName);
|
restrict.append(", ").append(targetName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
restrictCount++;
|
restrictCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
includeBlock = includeListMaterial.toString();
|
includeBlock = includeListMaterial.toString();
|
||||||
includeEntity = includeListEntity.toString();
|
includeEntity = includeListEntity.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity) {
|
if (entity) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ACTION_NOT_SUPPORTED));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ACTION_NOT_SUPPORTED));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean optimizeCheck = false;
|
boolean optimizeCheck = false;
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
|
|
||||||
if (arg.trim().equalsIgnoreCase("#optimize")) {
|
if (arg.trim().equalsIgnoreCase("#optimize")) {
|
||||||
|
|
||||||
optimizeCheck = true;
|
optimizeCheck = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder restrictTargets = restrict;
|
final StringBuilder restrictTargets = restrict;
|
||||||
@@ -194,7 +243,9 @@ public class PurgeCommand extends Consumer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
long timestamp = (System.currentTimeMillis() / 1000L);
|
long timestamp = (System.currentTimeMillis() / 1000L);
|
||||||
long timeStart = startTime > 0 ? (timestamp - startTime) : 0;
|
long timeStart = startTime > 0 ? (timestamp - startTime) : 0;
|
||||||
long timeEnd = timestamp - endTime;
|
long timeEnd = timestamp - endTime;
|
||||||
@@ -202,34 +253,42 @@ public class PurgeCommand extends Consumer {
|
|||||||
|
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
for (int i = 0; i <= 5; i++) {
|
for (int i = 0; i <= 5; i++) {
|
||||||
|
|
||||||
connection = Database.getConnection(false, 500);
|
connection = Database.getConnection(false, 500);
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
|
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.DATABASE_BUSY));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.DATABASE_BUSY));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argWid > 0) {
|
if (argWid > 0) {
|
||||||
|
|
||||||
String worldName = CommandHandler.parseWorldName(args, false);
|
String worldName = CommandHandler.parseWorldName(args, false);
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_STARTED, worldName));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_STARTED, worldName));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_STARTED, "#global"));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_STARTED, "#global"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasBlockRestriction) {
|
if (hasBlockRestriction) {
|
||||||
Chat.sendGlobalMessage(
|
|
||||||
player,
|
Chat.sendGlobalMessage(player,
|
||||||
Phrase.build(
|
Phrase.build(Phrase.ROLLBACK_INCLUDE, restrictTargets.toString(), Selector.FIRST,
|
||||||
Phrase.ROLLBACK_INCLUDE,
|
Selector.FIRST, (restrictCountFinal == 1 ? Selector.FIRST : Selector.SECOND))); // include
|
||||||
restrictTargets.toString(),
|
|
||||||
Selector.FIRST,
|
|
||||||
Selector.FIRST,
|
|
||||||
(restrictCountFinal == 1 ? Selector.FIRST : Selector.SECOND))); // include
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_NOTICE_1));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_NOTICE_1));
|
||||||
@@ -237,8 +296,11 @@ public class PurgeCommand extends Consumer {
|
|||||||
|
|
||||||
ConfigHandler.purgeRunning = true;
|
ConfigHandler.purgeRunning = true;
|
||||||
while (!Consumer.pausedSuccess) {
|
while (!Consumer.pausedSuccess) {
|
||||||
|
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Consumer.isPaused = true;
|
Consumer.isPaused = true;
|
||||||
|
|
||||||
String query = "";
|
String query = "";
|
||||||
@@ -247,215 +309,309 @@ public class PurgeCommand extends Consumer {
|
|||||||
String purgePrefix = "tmp_" + ConfigHandler.prefix;
|
String purgePrefix = "tmp_" + ConfigHandler.prefix;
|
||||||
|
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
query = "ATTACH DATABASE '" + ConfigHandler.path + ConfigHandler.sqlite + ".tmp' AS tmp_db";
|
query = "ATTACH DATABASE '" + ConfigHandler.path + ConfigHandler.sqlite + ".tmp' AS tmp_db";
|
||||||
preparedStmt = connection.prepareStatement(query);
|
preparedStmt = connection.prepareStatement(query);
|
||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
purgePrefix = "tmp_db." + ConfigHandler.prefix;
|
purgePrefix = "tmp_db." + ConfigHandler.prefix;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer[] lastVersion = Patch.getDatabaseVersion(connection, true);
|
Integer[] lastVersion = Patch.getDatabaseVersion(connection, true);
|
||||||
boolean newVersion = Util.newVersion(lastVersion, Util.getInternalPluginVersion());
|
boolean newVersion = Util.newVersion(lastVersion, Util.getInternalPluginVersion());
|
||||||
if (newVersion && !ConfigHandler.EDITION_BRANCH.contains("-dev")) {
|
if (newVersion && !ConfigHandler.EDITION_BRANCH.contains("-dev")) {
|
||||||
|
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_FAILED));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_FAILED));
|
||||||
Consumer.isPaused = false;
|
Consumer.isPaused = false;
|
||||||
ConfigHandler.purgeRunning = false;
|
ConfigHandler.purgeRunning = false;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
for (String table : ConfigHandler.databaseTables) {
|
for (String table : ConfigHandler.databaseTables) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
query = "DROP TABLE IF EXISTS " + purgePrefix + table + "";
|
query = "DROP TABLE IF EXISTS " + purgePrefix + table + "";
|
||||||
preparedStmt = connection.prepareStatement(query);
|
preparedStmt = connection.prepareStatement(query);
|
||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.createDatabaseTables(purgePrefix, null, Config.getGlobal().MYSQL, true);
|
Database.createDatabaseTables(purgePrefix, null, Config.getGlobal().MYSQL, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> purgeTables = Arrays.asList(
|
List<String> purgeTables = Arrays.asList("sign", "container", "item", "skull", "session", "chat",
|
||||||
"sign", "container", "item", "skull", "session", "chat", "command", "entity", "block");
|
"command", "entity", "block");
|
||||||
List<String> worldTables =
|
List<String> worldTables = Arrays.asList("sign", "container", "item", "session", "chat", "command",
|
||||||
Arrays.asList("sign", "container", "item", "session", "chat", "command", "block");
|
"block");
|
||||||
List<String> restrictTables = Arrays.asList("block");
|
List<String> restrictTables = Arrays.asList("block");
|
||||||
List<String> excludeTables = Arrays.asList("database_lock"); // don't insert data into these tables
|
List<String> excludeTables = Arrays.asList("database_lock"); // don't insert data into these tables
|
||||||
for (String table : ConfigHandler.databaseTables) {
|
for (String table : ConfigHandler.databaseTables) {
|
||||||
|
|
||||||
String tableName = table.replaceAll("_", " ");
|
String tableName = table.replaceAll("_", " ");
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_PROCESSING, tableName));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_PROCESSING, tableName));
|
||||||
|
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
String columns = "";
|
String columns = "";
|
||||||
ResultSet rs =
|
ResultSet rs = connection.createStatement()
|
||||||
connection.createStatement().executeQuery("SELECT * FROM " + purgePrefix + table);
|
.executeQuery("SELECT * FROM " + purgePrefix + table);
|
||||||
ResultSetMetaData resultSetMetaData = rs.getMetaData();
|
ResultSetMetaData resultSetMetaData = rs.getMetaData();
|
||||||
int columnCount = resultSetMetaData.getColumnCount();
|
int columnCount = resultSetMetaData.getColumnCount();
|
||||||
for (int i = 1; i <= columnCount; i++) {
|
for (int i = 1; i <= columnCount; i++) {
|
||||||
|
|
||||||
String name = resultSetMetaData.getColumnName(i);
|
String name = resultSetMetaData.getColumnName(i);
|
||||||
if (columns.length() == 0) {
|
if (columns.length() == 0) {
|
||||||
|
|
||||||
columns = name;
|
columns = name;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
columns = columns + "," + name;
|
columns = columns + "," + name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
if (!excludeTables.contains(table)) {
|
if (!excludeTables.contains(table)) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
boolean purge = true;
|
boolean purge = true;
|
||||||
String timeLimit = "";
|
String timeLimit = "";
|
||||||
if (purgeTables.contains(table)) {
|
if (purgeTables.contains(table)) {
|
||||||
|
|
||||||
String blockRestriction = "(";
|
String blockRestriction = "(";
|
||||||
if (hasBlockRestriction && restrictTables.contains(table)) {
|
if (hasBlockRestriction && restrictTables.contains(table)) {
|
||||||
|
|
||||||
blockRestriction = "type NOT IN(" + includeBlockFinal + ") OR (type IN("
|
blockRestriction = "type NOT IN(" + includeBlockFinal + ") OR (type IN("
|
||||||
+ includeBlockFinal + ") AND ";
|
+ includeBlockFinal + ") AND ";
|
||||||
|
|
||||||
} else if (hasBlockRestriction) {
|
} else if (hasBlockRestriction) {
|
||||||
|
|
||||||
purge = false;
|
purge = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argWid > 0 && worldTables.contains(table)) {
|
if (argWid > 0 && worldTables.contains(table)) {
|
||||||
|
|
||||||
timeLimit = " WHERE (" + blockRestriction + "wid = '" + argWid
|
timeLimit = " WHERE (" + blockRestriction + "wid = '" + argWid
|
||||||
+ "' AND (time >= '" + timeEnd + "' OR time < '" + timeStart
|
+ "' AND (time >= '" + timeEnd + "' OR time < '" + timeStart
|
||||||
+ "'))) OR (wid != '" + argWid + "')";
|
+ "'))) OR (wid != '" + argWid + "')";
|
||||||
|
|
||||||
} else if (argWid == 0 && purge) {
|
} else if (argWid == 0 && purge) {
|
||||||
|
|
||||||
timeLimit = " WHERE " + blockRestriction + "(time >= '" + timeEnd
|
timeLimit = " WHERE " + blockRestriction + "(time >= '" + timeEnd
|
||||||
+ "' OR time < '" + timeStart + "'))";
|
+ "' OR time < '" + timeStart + "'))";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
query = "INSERT INTO " + purgePrefix + table + " SELECT " + columns + " FROM "
|
query = "INSERT INTO " + purgePrefix + table + " SELECT " + columns + " FROM "
|
||||||
+ ConfigHandler.prefix + table + timeLimit;
|
+ ConfigHandler.prefix + table + timeLimit;
|
||||||
preparedStmt = connection.prepareStatement(query);
|
preparedStmt = connection.prepareStatement(query);
|
||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_ERROR, tableName));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_ERROR, tableName));
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_REPAIRING));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_REPAIRING));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
query = "DELETE FROM " + purgePrefix + table;
|
query = "DELETE FROM " + purgePrefix + table;
|
||||||
preparedStmt = connection.prepareStatement(query);
|
preparedStmt = connection.prepareStatement(query);
|
||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
query = "REINDEX " + ConfigHandler.prefix + table;
|
query = "REINDEX " + ConfigHandler.prefix + table;
|
||||||
preparedStmt = connection.prepareStatement(query);
|
preparedStmt = connection.prepareStatement(query);
|
||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String index = " NOT INDEXED";
|
String index = " NOT INDEXED";
|
||||||
query = "INSERT INTO " + purgePrefix + table + " SELECT " + columns + " FROM "
|
query = "INSERT INTO " + purgePrefix + table + " SELECT " + columns + " FROM "
|
||||||
+ ConfigHandler.prefix + table + index;
|
+ ConfigHandler.prefix + table + index;
|
||||||
preparedStmt = connection.prepareStatement(query);
|
preparedStmt = connection.prepareStatement(query);
|
||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
abort = true;
|
abort = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
boolean purge = purgeTables.contains(table);
|
boolean purge = purgeTables.contains(table);
|
||||||
|
|
||||||
String blockRestriction = "";
|
String blockRestriction = "";
|
||||||
if (hasBlockRestriction && restrictTables.contains(table)) {
|
if (hasBlockRestriction && restrictTables.contains(table)) {
|
||||||
|
|
||||||
blockRestriction = "type IN(" + includeBlockFinal + ") AND ";
|
blockRestriction = "type IN(" + includeBlockFinal + ") AND ";
|
||||||
|
|
||||||
} else if (hasBlockRestriction) {
|
} else if (hasBlockRestriction) {
|
||||||
|
|
||||||
purge = false;
|
purge = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String worldRestriction = "";
|
String worldRestriction = "";
|
||||||
if (argWid > 0 && worldTables.contains(table)) {
|
if (argWid > 0 && worldTables.contains(table)) {
|
||||||
|
|
||||||
worldRestriction = " AND wid = '" + argWid + "'";
|
worldRestriction = " AND wid = '" + argWid + "'";
|
||||||
|
|
||||||
} else if (argWid > 0) {
|
} else if (argWid > 0) {
|
||||||
|
|
||||||
purge = false;
|
purge = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (purge) {
|
if (purge) {
|
||||||
|
|
||||||
query = "DELETE FROM " + purgePrefix + table + " WHERE " + blockRestriction
|
query = "DELETE FROM " + purgePrefix + table + " WHERE " + blockRestriction
|
||||||
+ "time < '" + timeEnd + "' AND time >= '" + timeStart + "'"
|
+ "time < '" + timeEnd + "' AND time >= '" + timeStart + "'"
|
||||||
+ worldRestriction;
|
+ worldRestriction;
|
||||||
preparedStmt = connection.prepareStatement(query);
|
preparedStmt = connection.prepareStatement(query);
|
||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (purgeTables.contains(table)) {
|
if (purgeTables.contains(table)) {
|
||||||
|
|
||||||
int oldCount = 0;
|
int oldCount = 0;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
query = "SELECT COUNT(*) as count FROM " + ConfigHandler.prefix + table
|
query = "SELECT COUNT(*) as count FROM " + ConfigHandler.prefix + table
|
||||||
+ " LIMIT 0, 1";
|
+ " LIMIT 0, 1";
|
||||||
preparedStmt = connection.prepareStatement(query);
|
preparedStmt = connection.prepareStatement(query);
|
||||||
ResultSet resultSet = preparedStmt.executeQuery();
|
ResultSet resultSet = preparedStmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
|
|
||||||
oldCount = resultSet.getInt("count");
|
oldCount = resultSet.getInt("count");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int new_count = 0;
|
int new_count = 0;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
query = "SELECT COUNT(*) as count FROM " + purgePrefix + table + " LIMIT 0, 1";
|
query = "SELECT COUNT(*) as count FROM " + purgePrefix + table + " LIMIT 0, 1";
|
||||||
preparedStmt = connection.prepareStatement(query);
|
preparedStmt = connection.prepareStatement(query);
|
||||||
ResultSet resultSet = preparedStmt.executeQuery();
|
ResultSet resultSet = preparedStmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
|
|
||||||
new_count = resultSet.getInt("count");
|
new_count = resultSet.getInt("count");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removed = removed + (oldCount - new_count);
|
removed = removed + (oldCount - new_count);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getGlobal().MYSQL) {
|
if (Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
boolean purge = purgeTables.contains(table);
|
boolean purge = purgeTables.contains(table);
|
||||||
|
|
||||||
String blockRestriction = "";
|
String blockRestriction = "";
|
||||||
if (hasBlockRestriction && restrictTables.contains(table)) {
|
if (hasBlockRestriction && restrictTables.contains(table)) {
|
||||||
|
|
||||||
blockRestriction = "type IN(" + includeBlockFinal + ") AND ";
|
blockRestriction = "type IN(" + includeBlockFinal + ") AND ";
|
||||||
|
|
||||||
} else if (hasBlockRestriction) {
|
} else if (hasBlockRestriction) {
|
||||||
|
|
||||||
purge = false;
|
purge = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String worldRestriction = "";
|
String worldRestriction = "";
|
||||||
if (argWid > 0 && worldTables.contains(table)) {
|
if (argWid > 0 && worldTables.contains(table)) {
|
||||||
|
|
||||||
worldRestriction = " AND wid = '" + argWid + "'";
|
worldRestriction = " AND wid = '" + argWid + "'";
|
||||||
|
|
||||||
} else if (argWid > 0) {
|
} else if (argWid > 0) {
|
||||||
|
|
||||||
purge = false;
|
purge = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (purge) {
|
if (purge) {
|
||||||
|
|
||||||
query = "DELETE FROM " + ConfigHandler.prefix + table + " WHERE " + blockRestriction
|
query = "DELETE FROM " + ConfigHandler.prefix + table + " WHERE " + blockRestriction
|
||||||
+ "time < '" + timeEnd + "' AND time >= '" + timeStart + "'"
|
+ "time < '" + timeEnd + "' AND time >= '" + timeStart + "'"
|
||||||
+ worldRestriction;
|
+ worldRestriction;
|
||||||
@@ -463,68 +619,91 @@ public class PurgeCommand extends Consumer {
|
|||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
removed = removed + preparedStmt.getUpdateCount();
|
removed = removed + preparedStmt.getUpdateCount();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
if (!ConfigHandler.serverRunning) {
|
if (!ConfigHandler.serverRunning) {
|
||||||
|
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_FAILED));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_FAILED));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getGlobal().MYSQL && optimize) {
|
if (Config.getGlobal().MYSQL && optimize) {
|
||||||
|
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_OPTIMIZING));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_OPTIMIZING));
|
||||||
for (String table : ConfigHandler.databaseTables) {
|
for (String table : ConfigHandler.databaseTables) {
|
||||||
|
|
||||||
query = "OPTIMIZE LOCAL TABLE " + ConfigHandler.prefix + table + "";
|
query = "OPTIMIZE LOCAL TABLE " + ConfigHandler.prefix + table + "";
|
||||||
preparedStmt = connection.prepareStatement(query);
|
preparedStmt = connection.prepareStatement(query);
|
||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.close();
|
connection.close();
|
||||||
|
|
||||||
if (abort) {
|
if (abort) {
|
||||||
|
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
(new File(ConfigHandler.path + ConfigHandler.sqlite + ".tmp")).delete();
|
(new File(ConfigHandler.path + ConfigHandler.sqlite + ".tmp")).delete();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.loadDatabase();
|
ConfigHandler.loadDatabase();
|
||||||
Chat.sendGlobalMessage(player, Color.RED + Phrase.build(Phrase.PURGE_ABORTED));
|
Chat.sendGlobalMessage(player, Color.RED + Phrase.build(Phrase.PURGE_ABORTED));
|
||||||
Consumer.isPaused = false;
|
Consumer.isPaused = false;
|
||||||
ConfigHandler.purgeRunning = false;
|
ConfigHandler.purgeRunning = false;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
(new File(ConfigHandler.path + ConfigHandler.sqlite)).delete();
|
(new File(ConfigHandler.path + ConfigHandler.sqlite)).delete();
|
||||||
(new File(ConfigHandler.path + ConfigHandler.sqlite + ".tmp"))
|
(new File(ConfigHandler.path + ConfigHandler.sqlite + ".tmp"))
|
||||||
.renameTo(new File(ConfigHandler.path + ConfigHandler.sqlite));
|
.renameTo(new File(ConfigHandler.path + ConfigHandler.sqlite));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.loadDatabase();
|
ConfigHandler.loadDatabase();
|
||||||
|
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_SUCCESS));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_SUCCESS));
|
||||||
Chat.sendGlobalMessage(
|
Chat.sendGlobalMessage(player,
|
||||||
player,
|
Phrase.build(Phrase.PURGE_ROWS, NumberFormat.getInstance().format(removed),
|
||||||
Phrase.build(
|
|
||||||
Phrase.PURGE_ROWS,
|
|
||||||
NumberFormat.getInstance().format(removed),
|
|
||||||
(removed == 1 ? Selector.FIRST : Selector.SECOND)));
|
(removed == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_FAILED));
|
Chat.sendGlobalMessage(player, Phrase.build(Phrase.PURGE_FAILED));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Consumer.isPaused = false;
|
Consumer.isPaused = false;
|
||||||
ConfigHandler.purgeRunning = false;
|
ConfigHandler.purgeRunning = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Runnable runnable = new BasicThread();
|
Runnable runnable = new BasicThread();
|
||||||
Thread thread = new Thread(runnable);
|
Thread thread = new Thread(runnable);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,70 +9,96 @@ import net.coreprotect.utility.Color;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class ReloadCommand {
|
public class ReloadCommand {
|
||||||
|
|
||||||
protected static void runCommand(final CommandSender player, boolean permission, String[] args) {
|
protected static void runCommand(final CommandSender player, boolean permission, String[] args) {
|
||||||
|
|
||||||
if (permission) {
|
if (permission) {
|
||||||
|
|
||||||
if (ConfigHandler.converterRunning) {
|
if (ConfigHandler.converterRunning) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||||
+ Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.purgeRunning) {
|
if (ConfigHandler.purgeRunning) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
|
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
|
||||||
|
|
||||||
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
|
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
|
||||||
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 100) {
|
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 100) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] {true, System.currentTimeMillis()});
|
|
||||||
|
ConfigHandler.lookupThrottle.put(player.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||||
|
|
||||||
class BasicThread implements Runnable {
|
class BasicThread implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (Consumer.isPaused) {
|
if (Consumer.isPaused) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.RELOAD_STARTED));
|
||||||
+ Phrase.build(Phrase.RELOAD_STARTED));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (Consumer.isPaused) {
|
while (Consumer.isPaused) {
|
||||||
|
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Consumer.isPaused = true;
|
Consumer.isPaused = true;
|
||||||
|
|
||||||
ConfigHandler.performInitialization(false);
|
ConfigHandler.performInitialization(false);
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
player,
|
+ Phrase.build(Phrase.RELOAD_SUCCESS));
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.RELOAD_SUCCESS));
|
|
||||||
|
|
||||||
Thread networkHandler = new Thread(new NetworkHandler(false, false));
|
Thread networkHandler = new Thread(new NetworkHandler(false, false));
|
||||||
networkHandler.start();
|
networkHandler.start();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Consumer.isPaused = false;
|
Consumer.isPaused = false;
|
||||||
ConfigHandler.lookupThrottle.put(
|
ConfigHandler.lookupThrottle.put(player.getName(),
|
||||||
player.getName(), new Object[] {false, System.currentTimeMillis()});
|
new Object[]
|
||||||
|
{ false, System.currentTimeMillis() });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Runnable runnable = new BasicThread();
|
Runnable runnable = new BasicThread();
|
||||||
Thread thread = new Thread(runnable);
|
Thread thread = new Thread(runnable);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
Chat.sendMessage(player,
|
||||||
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -30,14 +30,11 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class RollbackRestoreCommand {
|
public class RollbackRestoreCommand {
|
||||||
protected static void runCommand(
|
|
||||||
CommandSender player,
|
protected static void runCommand(CommandSender player, Command command, boolean permission, String[] args,
|
||||||
Command command,
|
Location argLocation, long forceStart, long forceEnd)
|
||||||
boolean permission,
|
{
|
||||||
String[] args,
|
|
||||||
Location argLocation,
|
|
||||||
long forceStart,
|
|
||||||
long forceEnd) {
|
|
||||||
Location lo = (argLocation != null ? argLocation : CommandHandler.parseLocation(player, args));
|
Location lo = (argLocation != null ? argLocation : CommandHandler.parseLocation(player, args));
|
||||||
List<String> argUuids = new ArrayList<>();
|
List<String> argUuids = new ArrayList<>();
|
||||||
List<String> argUsers = CommandHandler.parseUsers(args);
|
List<String> argUsers = CommandHandler.parseUsers(args);
|
||||||
@@ -59,273 +56,346 @@ public class RollbackRestoreCommand {
|
|||||||
String corecommand = args[0].toLowerCase(Locale.ROOT);
|
String corecommand = args[0].toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
if (argBlocks == null || argExclude == null || argExcludeUsers == null) {
|
if (argBlocks == null || argExclude == null || argExcludeUsers == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for invalid block/entity combinations (include) */
|
/* check for invalid block/entity combinations (include) */
|
||||||
boolean hasBlock = false;
|
boolean hasBlock = false;
|
||||||
boolean hasEntity = false;
|
boolean hasEntity = false;
|
||||||
for (Object arg : argBlocks) {
|
for (Object arg : argBlocks) {
|
||||||
|
|
||||||
if (arg instanceof Material) {
|
if (arg instanceof Material) {
|
||||||
|
|
||||||
hasBlock = true;
|
hasBlock = true;
|
||||||
|
|
||||||
} else if (arg instanceof EntityType) {
|
} else if (arg instanceof EntityType) {
|
||||||
|
|
||||||
hasEntity = true;
|
hasEntity = true;
|
||||||
if (argAction.size() == 0) {
|
if (argAction.size() == 0) {
|
||||||
|
|
||||||
argAction.add(3);
|
argAction.add(3);
|
||||||
|
|
||||||
} else if (!argAction.contains(3)) {
|
} else if (!argAction.contains(3)) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.INVALID_INCLUDE_COMBO));
|
||||||
+ Phrase.build(Phrase.INVALID_INCLUDE_COMBO));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for invalid block/entity combinations (exclude) */
|
/* check for invalid block/entity combinations (exclude) */
|
||||||
for (Object arg : argExclude.keySet()) {
|
for (Object arg : argExclude.keySet()) {
|
||||||
|
|
||||||
if (arg instanceof Material) {
|
if (arg instanceof Material) {
|
||||||
|
|
||||||
hasBlock = true;
|
hasBlock = true;
|
||||||
|
|
||||||
} else if (arg instanceof EntityType) {
|
} else if (arg instanceof EntityType) {
|
||||||
|
|
||||||
hasEntity = true;
|
hasEntity = true;
|
||||||
if (argAction.size() == 0) {
|
if (argAction.size() == 0) {
|
||||||
|
|
||||||
argAction.add(3);
|
argAction.add(3);
|
||||||
|
|
||||||
} else if (!argAction.contains(3)) {
|
} else if (!argAction.contains(3)) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.INVALID_INCLUDE_COMBO));
|
||||||
+ Phrase.build(Phrase.INVALID_INCLUDE_COMBO));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasBlock && hasEntity) {
|
if (hasBlock && hasEntity) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.INVALID_INCLUDE_COMBO));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.INVALID_INCLUDE_COMBO));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
|
|
||||||
LookupCommand.runCommand(player, command, permission, args);
|
LookupCommand.runCommand(player, command, permission, args);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.converterRunning) {
|
if (ConfigHandler.converterRunning) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.purgeRunning) {
|
if (ConfigHandler.purgeRunning) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_IN_PROGRESS));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argWid == -1) {
|
if (argWid == -1) {
|
||||||
|
|
||||||
String worldName = CommandHandler.parseWorldName(args, true);
|
String worldName = CommandHandler.parseWorldName(args, true);
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
player,
|
+ Phrase.build(Phrase.WORLD_NOT_FOUND, worldName));
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.WORLD_NOT_FOUND, worldName));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preview > 0 && (!(player instanceof Player))) {
|
if (preview > 0 && (!(player instanceof Player))) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PREVIEW_IN_GAME));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PREVIEW_IN_GAME));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argAction.contains(-1)) {
|
if (argAction.contains(-1)) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.INVALID_ACTION));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.INVALID_ACTION));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worldedit && argRadius == null) {
|
if (worldedit && argRadius == null) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.INVALID_SELECTION, "WorldEdit"));
|
||||||
+ Phrase.build(Phrase.INVALID_SELECTION, "WorldEdit"));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argRadius != null && argRadius[0] == -1) {
|
if (argRadius != null && argRadius[0] == -1) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.INVALID_RADIUS));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.INVALID_RADIUS));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.activeRollbacks.get(player.getName()) != null) {
|
if (ConfigHandler.activeRollbacks.get(player.getName()) != null) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_IN_PROGRESS));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_IN_PROGRESS));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
|
if (ConfigHandler.lookupThrottle.get(player.getName()) != null) {
|
||||||
|
|
||||||
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
|
Object[] lookupThrottle = ConfigHandler.lookupThrottle.get(player.getName());
|
||||||
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 100) {
|
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 100) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DATABASE_BUSY));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preview > 1 && forceStart <= 0) {
|
if (preview > 1 && forceStart <= 0) {
|
||||||
|
|
||||||
preview = 1;
|
preview = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permission) {
|
if (permission) {
|
||||||
|
|
||||||
int a = 0;
|
int a = 0;
|
||||||
if (corecommand.equals("restore") || corecommand.equals("rs") || corecommand.equals("re")) {
|
if (corecommand.equals("restore") || corecommand.equals("rs") || corecommand.equals("re")) {
|
||||||
|
|
||||||
a = 1;
|
a = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final int finalAction = a;
|
final int finalAction = a;
|
||||||
|
|
||||||
int DEFAULT_RADIUS = Config.getGlobal().DEFAULT_RADIUS;
|
int DEFAULT_RADIUS = Config.getGlobal().DEFAULT_RADIUS;
|
||||||
if ((player instanceof Player || player instanceof BlockCommandSender)
|
if ((player instanceof Player || player instanceof BlockCommandSender) && argRadius == null
|
||||||
&& argRadius == null
|
&& DEFAULT_RADIUS > 0 && !forceglobal && !argAction.contains(11))
|
||||||
&& DEFAULT_RADIUS > 0
|
{
|
||||||
&& !forceglobal
|
|
||||||
&& !argAction.contains(11)) {
|
|
||||||
Location location = lo;
|
Location location = lo;
|
||||||
int xmin = location.getBlockX() - DEFAULT_RADIUS;
|
int xmin = location.getBlockX() - DEFAULT_RADIUS;
|
||||||
int xmax = location.getBlockX() + DEFAULT_RADIUS;
|
int xmax = location.getBlockX() + DEFAULT_RADIUS;
|
||||||
int zmin = location.getBlockZ() - DEFAULT_RADIUS;
|
int zmin = location.getBlockZ() - DEFAULT_RADIUS;
|
||||||
int zmax = location.getBlockZ() + DEFAULT_RADIUS;
|
int zmax = location.getBlockZ() + DEFAULT_RADIUS;
|
||||||
argRadius = new Integer[] {DEFAULT_RADIUS, xmin, xmax, null, null, zmin, zmax, 0};
|
argRadius = new Integer[] { DEFAULT_RADIUS, xmin, xmax, null, null, zmin, zmax, 0 };
|
||||||
|
|
||||||
}
|
}
|
||||||
// if (arg_radius==-2)arg_radius = -1;
|
// if (arg_radius==-2)arg_radius = -1;
|
||||||
|
|
||||||
int g = 1;
|
int g = 1;
|
||||||
if (argUsers.contains("#global")) {
|
if (argUsers.contains("#global")) {
|
||||||
|
|
||||||
if (argRadius == null) {
|
if (argRadius == null) {
|
||||||
|
|
||||||
g = 0;
|
g = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argUsers.size() == 0 && (argWid > 0 || forceglobal) && argRadius == null) {
|
if (argUsers.size() == 0 && (argWid > 0 || forceglobal) && argRadius == null) {
|
||||||
|
|
||||||
if (finalAction == 0) {
|
if (finalAction == 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_ROLLBACK_USER, Selector.FIRST));
|
||||||
+ Phrase.build(Phrase.MISSING_ROLLBACK_USER, Selector.FIRST));
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_ROLLBACK_USER, Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.MISSING_ROLLBACK_USER, Selector.SECOND));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argAction.contains(4) && argAction.contains(11)) { // a:inventory
|
if (argAction.contains(4) && argAction.contains(11)) { // a:inventory
|
||||||
|
|
||||||
if (argUsers.size() == 0) {
|
if (argUsers.size() == 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_ACTION_USER));
|
||||||
+ Phrase.build(Phrase.MISSING_ACTION_USER));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
argExclude.put(Material.FIRE, false);
|
argExclude.put(Material.FIRE, false);
|
||||||
argExclude.put(Material.WATER, false);
|
argExclude.put(Material.WATER, false);
|
||||||
argExclude.put(Material.FARMLAND, false);
|
argExclude.put(Material.FARMLAND, false);
|
||||||
argExcludeUsers.add("#hopper");
|
argExcludeUsers.add("#hopper");
|
||||||
} else if (!argAction.contains(4)
|
|
||||||
&& Config.getGlobal().EXCLUDE_TNT
|
} else if (!argAction.contains(4) && Config.getGlobal().EXCLUDE_TNT && !argExclude.containsKey(Material.TNT)
|
||||||
&& !argExclude.containsKey(Material.TNT)
|
&& !argBlocks.contains(Material.TNT))
|
||||||
&& !argBlocks.contains(Material.TNT)) {
|
{
|
||||||
|
|
||||||
argExclude.put(Material.TNT, true);
|
argExclude.put(Material.TNT, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g == 1 && (argUsers.size() > 0 || (argUsers.size() == 0 && argRadius != null))) {
|
if (g == 1 && (argUsers.size() > 0 || (argUsers.size() == 0 && argRadius != null))) {
|
||||||
|
|
||||||
Integer MAX_RADIUS = Config.getGlobal().MAX_RADIUS;
|
Integer MAX_RADIUS = Config.getGlobal().MAX_RADIUS;
|
||||||
if (argRadius != null) {
|
if (argRadius != null) {
|
||||||
|
|
||||||
int radiusValue = argRadius[0];
|
int radiusValue = argRadius[0];
|
||||||
if (radiusValue > MAX_RADIUS && MAX_RADIUS > 0) {
|
if (radiusValue > MAX_RADIUS && MAX_RADIUS > 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.MAXIMUM_RADIUS, MAX_RADIUS.toString(),
|
||||||
Phrase.MAXIMUM_RADIUS,
|
|
||||||
MAX_RADIUS.toString(),
|
|
||||||
(finalAction == 0 ? Selector.SECOND : Selector.THIRD)));
|
(finalAction == 0 ? Selector.SECOND : Selector.THIRD)));
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player,
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.GLOBAL_ROLLBACK, "r:#global",
|
||||||
Phrase.GLOBAL_ROLLBACK,
|
|
||||||
"r:#global",
|
|
||||||
(finalAction == 0 ? Selector.FIRST : Selector.SECOND)));
|
(finalAction == 0 ? Selector.FIRST : Selector.SECOND)));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argAction.size() > 0) {
|
if (argAction.size() > 0) {
|
||||||
|
|
||||||
if (argAction.contains(4)) {
|
if (argAction.contains(4)) {
|
||||||
|
|
||||||
if (argUsers.contains("#global") || (argUsers.size() == 0 && argRadius == null)) {
|
if (argUsers.contains("#global") || (argUsers.size() == 0 && argRadius == null)) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_ACTION_USER));
|
||||||
+ Phrase.build(Phrase.MISSING_ACTION_USER));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (preview > 0) {
|
} else if (preview > 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.PREVIEW_TRANSACTION,
|
||||||
Phrase.PREVIEW_TRANSACTION,
|
|
||||||
!argAction.contains(11) ? Selector.FIRST : Selector.SECOND));
|
!argAction.contains(11) ? Selector.FIRST : Selector.SECOND));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (argAction.contains(8)
|
|
||||||
|| (argAction.contains(11) && !argAction.contains(4))
|
if (argAction.contains(8) || (argAction.contains(11) && !argAction.contains(4))
|
||||||
|| (!argAction.contains(0)
|
|| (!argAction.contains(0) && !argAction.contains(1) && !argAction.contains(3)
|
||||||
&& !argAction.contains(1)
|
&& !argAction.contains(4)))
|
||||||
&& !argAction.contains(3)
|
{
|
||||||
&& !argAction.contains(4))) {
|
|
||||||
if (finalAction == 0) {
|
if (finalAction == 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ACTION_NOT_SUPPORTED));
|
||||||
+ Phrase.build(Phrase.ACTION_NOT_SUPPORTED));
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ACTION_NOT_SUPPORTED));
|
||||||
+ Phrase.build(Phrase.ACTION_NOT_SUPPORTED));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argUsers.size() == 0) {
|
if (argUsers.size() == 0) {
|
||||||
|
|
||||||
argUsers.add("#global");
|
argUsers.add("#global");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> rollbackusers = argUsers;
|
List<String> rollbackusers = argUsers;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for (String ruser : rollbackusers) {
|
for (String ruser : rollbackusers) {
|
||||||
|
|
||||||
List<Player> players = Bukkit.getServer().matchPlayer(ruser); // here
|
List<Player> players = Bukkit.getServer().matchPlayer(ruser); // here
|
||||||
for (Player p : players) {
|
for (Player p : players) {
|
||||||
|
|
||||||
if (p.getName().equalsIgnoreCase(ruser)) {
|
if (p.getName().equalsIgnoreCase(ruser)) {
|
||||||
|
|
||||||
ruser = p.getName();
|
ruser = p.getName();
|
||||||
rollbackusers.set(c, ruser);
|
rollbackusers.set(c, ruser);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c++;
|
c++;
|
||||||
|
|
||||||
if (argAction.contains(4) && argAction.contains(11)) {
|
if (argAction.contains(4) && argAction.contains(11)) {
|
||||||
|
|
||||||
Player onlineUser = Bukkit.getServer().getPlayer(ruser);
|
Player onlineUser = Bukkit.getServer().getPlayer(ruser);
|
||||||
if (onlineUser == null || !onlineUser.isOnline()) {
|
if (onlineUser == null || !onlineUser.isOnline()) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.USER_OFFLINE, ruser));
|
||||||
+ Phrase.build(Phrase.USER_OFFLINE, ruser));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wid = 0;
|
int wid = 0;
|
||||||
@@ -333,33 +403,45 @@ public class RollbackRestoreCommand {
|
|||||||
int y = 0;
|
int y = 0;
|
||||||
int z = 0;
|
int z = 0;
|
||||||
if (rollbackusers.contains("#container")) {
|
if (rollbackusers.contains("#container")) {
|
||||||
|
|
||||||
if (argAction.contains(11)) {
|
if (argAction.contains(11)) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.INVALID_USERNAME, "#container"));
|
||||||
+ Phrase.build(Phrase.INVALID_USERNAME, "#container"));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean valid = false;
|
boolean valid = false;
|
||||||
if (ConfigHandler.lookupType.get(player.getName()) != null) {
|
if (ConfigHandler.lookupType.get(player.getName()) != null) {
|
||||||
|
|
||||||
int lookupType = ConfigHandler.lookupType.get(player.getName());
|
int lookupType = ConfigHandler.lookupType.get(player.getName());
|
||||||
if (lookupType == 1) {
|
if (lookupType == 1) {
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
||||||
} else if (lookupType == 5) {
|
} else if (lookupType == 5) {
|
||||||
|
|
||||||
if (ConfigHandler.lookupUlist.get(player.getName()).contains("#container")) {
|
if (ConfigHandler.lookupUlist.get(player.getName()).contains("#container")) {
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|
||||||
if (preview > 0) {
|
if (preview > 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.PREVIEW_TRANSACTION, Selector.FIRST));
|
||||||
+ Phrase.build(Phrase.PREVIEW_TRANSACTION, Selector.FIRST));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String lcommand = ConfigHandler.lookupCommand.get(player.getName());
|
String lcommand = ConfigHandler.lookupCommand.get(player.getName());
|
||||||
String[] data = lcommand.split("\\.");
|
String[] data = lcommand.split("\\.");
|
||||||
x = Integer.parseInt(data[0]);
|
x = Integer.parseInt(data[0]);
|
||||||
@@ -372,11 +454,13 @@ public class RollbackRestoreCommand {
|
|||||||
lo = new Location(Bukkit.getServer().getWorld(Util.getWorldName(wid)), x, y, z);
|
lo = new Location(Bukkit.getServer().getWorld(Util.getWorldName(wid)), x, y, z);
|
||||||
Block block = lo.getBlock();
|
Block block = lo.getBlock();
|
||||||
if (block.getState() instanceof Chest) {
|
if (block.getState() instanceof Chest) {
|
||||||
BlockFace[] blockFaces = new BlockFace[] {
|
|
||||||
BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST
|
BlockFace[] blockFaces = new BlockFace[] { BlockFace.NORTH, BlockFace.EAST,
|
||||||
};
|
BlockFace.SOUTH, BlockFace.WEST };
|
||||||
for (BlockFace face : blockFaces) {
|
for (BlockFace face : blockFaces) {
|
||||||
|
|
||||||
if (block.getRelative(face, 1).getState() instanceof Chest) {
|
if (block.getRelative(face, 1).getState() instanceof Chest) {
|
||||||
|
|
||||||
Block relative = block.getRelative(face, 1);
|
Block relative = block.getRelative(face, 1);
|
||||||
int x2 = relative.getX();
|
int x2 = relative.getX();
|
||||||
int z2 = relative.getZ();
|
int z2 = relative.getZ();
|
||||||
@@ -385,32 +469,43 @@ public class RollbackRestoreCommand {
|
|||||||
lo.setX(newX);
|
lo.setX(newX);
|
||||||
lo.setZ(newZ);
|
lo.setZ(newZ);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.INVALID_CONTAINER));
|
||||||
+ Phrase.build(Phrase.INVALID_CONTAINER));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> rollbackusers2 = rollbackusers;
|
final List<String> rollbackusers2 = rollbackusers;
|
||||||
if (startTime > 0) {
|
if (startTime > 0) {
|
||||||
|
|
||||||
long unixtimestamp = (System.currentTimeMillis() / 1000L);
|
long unixtimestamp = (System.currentTimeMillis() / 1000L);
|
||||||
long timeStart = unixtimestamp - startTime;
|
long timeStart = unixtimestamp - startTime;
|
||||||
long timeEnd = endTime > 0 ? (unixtimestamp - endTime) : 0;
|
long timeEnd = endTime > 0 ? (unixtimestamp - endTime) : 0;
|
||||||
if (forceStart > 0) {
|
if (forceStart > 0) {
|
||||||
|
|
||||||
timeStart = forceStart;
|
timeStart = forceStart;
|
||||||
timeEnd = forceEnd;
|
timeEnd = forceEnd;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final long finalTimeStart = timeStart;
|
final long finalTimeStart = timeStart;
|
||||||
final long finalTimeEnd = timeEnd;
|
final long finalTimeEnd = timeEnd;
|
||||||
final Integer[] radius = argRadius;
|
final Integer[] radius = argRadius;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
final CommandSender player2 = player;
|
final CommandSender player2 = player;
|
||||||
final int noisy = argNoisy;
|
final int noisy = argNoisy;
|
||||||
final String rtime = ts;
|
final String rtime = ts;
|
||||||
@@ -427,213 +522,257 @@ public class RollbackRestoreCommand {
|
|||||||
ConfigHandler.activeRollbacks.put(player.getName(), true);
|
ConfigHandler.activeRollbacks.put(player.getName(), true);
|
||||||
|
|
||||||
class BasicThread2 implements Runnable {
|
class BasicThread2 implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try (Connection connection = Database.getConnection(false, 1000)) {
|
try (Connection connection = Database.getConnection(false, 1000)) {
|
||||||
ConfigHandler.lookupThrottle.put(
|
|
||||||
player.getName(), new Object[] {true, System.currentTimeMillis()});
|
ConfigHandler.lookupThrottle.put(player.getName(),
|
||||||
|
new Object[]
|
||||||
|
{ true, System.currentTimeMillis() });
|
||||||
int action = finalAction;
|
int action = finalAction;
|
||||||
Location location = locationFinal;
|
Location location = locationFinal;
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
|
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
String baduser = "";
|
String baduser = "";
|
||||||
boolean exists = false;
|
boolean exists = false;
|
||||||
for (String check : rollbackusers2) {
|
for (String check : rollbackusers2) {
|
||||||
|
|
||||||
if (!check.equals("#global") && !check.equals("#container")) {
|
if (!check.equals("#global") && !check.equals("#container")) {
|
||||||
|
|
||||||
exists = PlayerLookup.playerExists(connection, check);
|
exists = PlayerLookup.playerExists(connection, check);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
|
|
||||||
baduser = check;
|
baduser = check;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
exists = true;
|
exists = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
|
|
||||||
for (String check : euserlist) {
|
for (String check : euserlist) {
|
||||||
|
|
||||||
if (!check.equals("#global") && !check.equals("#hopper")) {
|
if (!check.equals("#global") && !check.equals("#hopper")) {
|
||||||
|
|
||||||
exists = PlayerLookup.playerExists(connection, check);
|
exists = PlayerLookup.playerExists(connection, check);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
|
|
||||||
baduser = check;
|
baduser = check;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (check.equals("#global")) {
|
} else if (check.equals("#global")) {
|
||||||
|
|
||||||
baduser = "#global";
|
baduser = "#global";
|
||||||
exists = false;
|
exists = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
|
|
||||||
boolean restrictWorld = false;
|
boolean restrictWorld = false;
|
||||||
if (radius != null) {
|
if (radius != null) {
|
||||||
|
|
||||||
restrictWorld = true;
|
restrictWorld = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
|
|
||||||
restrictWorld = false;
|
restrictWorld = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalArgWid > 0) {
|
if (finalArgWid > 0) {
|
||||||
|
|
||||||
restrictWorld = true;
|
restrictWorld = true;
|
||||||
location = new Location(
|
location = new Location(
|
||||||
Bukkit.getServer().getWorld(Util.getWorldName(finalArgWid)),
|
Bukkit.getServer().getWorld(Util.getWorldName(finalArgWid)), 0,
|
||||||
0,
|
0, 0);
|
||||||
0,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean verbose = false;
|
boolean verbose = false;
|
||||||
if (noisy == 1) {
|
if (noisy == 1) {
|
||||||
|
|
||||||
verbose = true;
|
verbose = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String users = "";
|
String users = "";
|
||||||
for (String value : rollbackusers2) {
|
for (String value : rollbackusers2) {
|
||||||
|
|
||||||
if (users.length() == 0) {
|
if (users.length() == 0) {
|
||||||
|
|
||||||
users = "" + value + "";
|
users = "" + value + "";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
users = users + ", " + value;
|
users = users + ", " + value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (users.equals("#global") && restrictWorld) {
|
if (users.equals("#global") && restrictWorld) {
|
||||||
|
|
||||||
// chat output only, don't pass into any functions
|
// chat output only, don't pass into any functions
|
||||||
users = "#"
|
users = "#" + location.getWorld().getName();
|
||||||
+ location.getWorld().getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalPreview == 2) {
|
if (finalPreview == 2) {
|
||||||
Chat.sendMessage(
|
|
||||||
player2,
|
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ "- " + Phrase.build(Phrase.PREVIEW_CANCELLING));
|
||||||
+ Phrase.build(Phrase.PREVIEW_CANCELLING));
|
|
||||||
} else if (finalPreview == 1) {
|
} else if (finalPreview == 1) {
|
||||||
Chat.sendMessage(
|
|
||||||
player2,
|
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.ROLLBACK_STARTED, users, Selector.THIRD));
|
||||||
Phrase.ROLLBACK_STARTED,
|
|
||||||
users,
|
|
||||||
Selector.THIRD));
|
|
||||||
} else if (action == 0) {
|
} else if (action == 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player2,
|
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.ROLLBACK_STARTED, users, Selector.FIRST));
|
||||||
Phrase.ROLLBACK_STARTED,
|
|
||||||
users,
|
|
||||||
Selector.FIRST));
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player2,
|
Chat.sendMessage(player2,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.ROLLBACK_STARTED, users,
|
||||||
Phrase.ROLLBACK_STARTED,
|
|
||||||
users,
|
|
||||||
Selector.SECOND));
|
Selector.SECOND));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalArgAction.contains(5)) {
|
if (finalArgAction.contains(5)) {
|
||||||
ContainerRollback.performContainerRollbackRestore(
|
|
||||||
statement,
|
ContainerRollback.performContainerRollbackRestore(statement, player2,
|
||||||
player2,
|
uuidList, rollbackusers2, rtime, blist, elist, euserlist,
|
||||||
uuidList,
|
finalArgAction, location, radius, finalTimeStart, finalTimeEnd,
|
||||||
rollbackusers2,
|
restrictWorld, false, verbose, action);
|
||||||
rtime,
|
|
||||||
blist,
|
|
||||||
elist,
|
|
||||||
euserlist,
|
|
||||||
finalArgAction,
|
|
||||||
location,
|
|
||||||
radius,
|
|
||||||
finalTimeStart,
|
|
||||||
finalTimeEnd,
|
|
||||||
restrictWorld,
|
|
||||||
false,
|
|
||||||
verbose,
|
|
||||||
action);
|
|
||||||
} else {
|
} else {
|
||||||
Rollback.performRollbackRestore(
|
|
||||||
statement,
|
Rollback.performRollbackRestore(statement, player2, uuidList,
|
||||||
player2,
|
rollbackusers2, rtime, blist, elist, euserlist, finalArgAction,
|
||||||
uuidList,
|
location, radius, finalTimeStart, finalTimeEnd, restrictWorld,
|
||||||
rollbackusers2,
|
false, verbose, action, finalPreview);
|
||||||
rtime,
|
|
||||||
blist,
|
|
||||||
elist,
|
|
||||||
euserlist,
|
|
||||||
finalArgAction,
|
|
||||||
location,
|
|
||||||
radius,
|
|
||||||
finalTimeStart,
|
|
||||||
finalTimeEnd,
|
|
||||||
restrictWorld,
|
|
||||||
false,
|
|
||||||
verbose,
|
|
||||||
action,
|
|
||||||
finalPreview);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalPreview < 2) {
|
if (finalPreview < 2) {
|
||||||
|
|
||||||
List<Object> list = new ArrayList<>();
|
List<Object> list = new ArrayList<>();
|
||||||
list.add(finalTimeStart);
|
list.add(finalTimeStart);
|
||||||
list.add(finalTimeEnd);
|
list.add(finalTimeEnd);
|
||||||
list.add(finalArgs);
|
list.add(finalArgs);
|
||||||
list.add(locationFinal);
|
list.add(locationFinal);
|
||||||
ConfigHandler.lastRollback.put(player2.getName(), list);
|
ConfigHandler.lastRollback.put(player2.getName(), list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player2,
|
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ "- " + Phrase.build(Phrase.USER_NOT_FOUND, baduser));
|
||||||
+ Phrase.build(Phrase.USER_NOT_FOUND, baduser));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player2,
|
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.DATABASE_BUSY));
|
||||||
+ Phrase.build(Phrase.DATABASE_BUSY));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.activeRollbacks.get(player2.getName()) != null) {
|
if (ConfigHandler.activeRollbacks.get(player2.getName()) != null) {
|
||||||
|
|
||||||
ConfigHandler.activeRollbacks.remove(player2.getName());
|
ConfigHandler.activeRollbacks.remove(player2.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
ConfigHandler.lookupThrottle.put(
|
|
||||||
player2.getName(), new Object[] {false, System.currentTimeMillis()});
|
ConfigHandler.lookupThrottle.put(player2.getName(),
|
||||||
|
new Object[]
|
||||||
|
{ false, System.currentTimeMillis() });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Runnable runnable = new BasicThread2();
|
Runnable runnable = new BasicThread2();
|
||||||
Thread thread = new Thread(runnable);
|
Thread thread = new Thread(runnable);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (finalAction == 0) {
|
if (finalAction == 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_LOOKUP_TIME, Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.MISSING_LOOKUP_TIME, Selector.SECOND));
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_LOOKUP_TIME, Selector.THIRD));
|
||||||
+ Phrase.build(Phrase.MISSING_LOOKUP_TIME, Selector.THIRD));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (finalAction == 0) {
|
if (finalAction == 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_ROLLBACK_RADIUS, Selector.FIRST)); // rollback
|
||||||
+ Phrase.build(Phrase.MISSING_ROLLBACK_RADIUS, Selector.FIRST)); // rollback
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_ROLLBACK_RADIUS, Selector.SECOND)); // restore
|
||||||
+ Phrase.build(Phrase.MISSING_ROLLBACK_RADIUS, Selector.SECOND)); // restore
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
Chat.sendMessage(player,
|
||||||
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,205 +18,234 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
|
||||||
public class StatusCommand {
|
public class StatusCommand {
|
||||||
|
|
||||||
private static ConcurrentHashMap<String, Boolean> alert = new ConcurrentHashMap<>();
|
private static ConcurrentHashMap<String, Boolean> alert = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
||||||
|
|
||||||
if (!permission) {
|
if (!permission) {
|
||||||
Chat.sendMessage(
|
|
||||||
player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
Chat.sendMessage(player,
|
||||||
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class BasicThread implements Runnable {
|
class BasicThread implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
CoreProtect instance = CoreProtect.getInstance();
|
CoreProtect instance = CoreProtect.getInstance();
|
||||||
PluginDescriptionFile pdfFile = instance.getDescription();
|
PluginDescriptionFile pdfFile = instance.getDescription();
|
||||||
|
|
||||||
String versionCheck = "";
|
String versionCheck = "";
|
||||||
if (Config.getGlobal().CHECK_UPDATES) {
|
if (Config.getGlobal().CHECK_UPDATES) {
|
||||||
|
|
||||||
String latestVersion = NetworkHandler.latestVersion();
|
String latestVersion = NetworkHandler.latestVersion();
|
||||||
if (latestVersion != null) {
|
if (latestVersion != null) {
|
||||||
|
|
||||||
versionCheck = " (" + Phrase.build(Phrase.LATEST_VERSION, "v" + latestVersion) + ")";
|
versionCheck = " (" + Phrase.build(Phrase.LATEST_VERSION, "v" + latestVersion) + ")";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player,
|
||||||
player,
|
|
||||||
Color.WHITE + "----- " + Color.DARK_AQUA + "CoreProtect"
|
Color.WHITE + "----- " + Color.DARK_AQUA + "CoreProtect"
|
||||||
+ (Util.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "")
|
+ (Util.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "")
|
||||||
+ Color.WHITE + " -----");
|
+ Color.WHITE + " -----");
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player,
|
||||||
player,
|
|
||||||
Color.DARK_AQUA
|
Color.DARK_AQUA
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.STATUS_VERSION, Color.WHITE,
|
||||||
Phrase.STATUS_VERSION,
|
|
||||||
Color.WHITE,
|
|
||||||
ConfigHandler.EDITION_NAME + " v" + pdfFile.getVersion() + ".")
|
ConfigHandler.EDITION_NAME + " v" + pdfFile.getVersion() + ".")
|
||||||
+ versionCheck);
|
+ versionCheck);
|
||||||
|
|
||||||
String donationKey = NetworkHandler.donationKey();
|
String donationKey = NetworkHandler.donationKey();
|
||||||
if (donationKey != null) {
|
if (donationKey != null) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.STATUS_LICENSE, Color.WHITE,
|
||||||
Color.DARK_AQUA
|
Phrase.build(Phrase.VALID_DONATION_KEY)) + " (" + donationKey + ")");
|
||||||
+ Phrase.build(
|
|
||||||
Phrase.STATUS_LICENSE,
|
|
||||||
Color.WHITE,
|
|
||||||
Phrase.build(Phrase.VALID_DONATION_KEY))
|
|
||||||
+ " (" + donationKey + ")");
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA
|
Color.DARK_AQUA
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.STATUS_LICENSE, Color.WHITE,
|
||||||
Phrase.STATUS_LICENSE,
|
|
||||||
Color.WHITE,
|
|
||||||
Phrase.build(Phrase.INVALID_DONATION_KEY))
|
Phrase.build(Phrase.INVALID_DONATION_KEY))
|
||||||
+ Color.GREY + Color.ITALIC + " (" + Phrase.build(Phrase.CHECK_CONFIG) + ")");
|
+ Color.GREY + Color.ITALIC + " (" + Phrase.build(Phrase.CHECK_CONFIG) + ")");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Items processed (since server start)
|
* Items processed (since server start) Items processed (last 60 minutes)
|
||||||
Items processed (last 60 minutes)
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
// Using MySQL/SQLite (Database Size: 587MB)
|
// Using MySQL/SQLite (Database Size: 587MB)
|
||||||
|
|
||||||
String firstVersion = Patch.getFirstVersion();
|
String firstVersion = Patch.getFirstVersion();
|
||||||
if (firstVersion.length() > 0) {
|
if (firstVersion.length() > 0) {
|
||||||
|
|
||||||
firstVersion = " (" + Phrase.build(Phrase.FIRST_VERSION, firstVersion) + ")";
|
firstVersion = " (" + Phrase.build(Phrase.FIRST_VERSION, firstVersion) + ")";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getGlobal().MYSQL) {
|
if (Config.getGlobal().MYSQL) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA
|
||||||
Color.DARK_AQUA
|
+ Phrase.build(Phrase.STATUS_DATABASE, Color.WHITE, "MySQL") + firstVersion);
|
||||||
+ Phrase.build(Phrase.STATUS_DATABASE, Color.WHITE, "MySQL")
|
|
||||||
+ firstVersion);
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA
|
||||||
Color.DARK_AQUA
|
+ Phrase.build(Phrase.STATUS_DATABASE, Color.WHITE, "SQLite") + firstVersion);
|
||||||
+ Phrase.build(Phrase.STATUS_DATABASE, Color.WHITE, "SQLite")
|
|
||||||
+ firstVersion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.worldeditEnabled) {
|
if (ConfigHandler.worldeditEnabled) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA
|
||||||
Color.DARK_AQUA
|
+ Phrase.build(Phrase.STATUS_INTEGRATION, Color.WHITE, "WorldEdit", Selector.FIRST));
|
||||||
+ Phrase.build(
|
|
||||||
Phrase.STATUS_INTEGRATION, Color.WHITE, "WorldEdit", Selector.FIRST));
|
|
||||||
} else if (instance.getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
} else if (instance.getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA
|
||||||
Color.DARK_AQUA
|
+ Phrase.build(Phrase.STATUS_INTEGRATION, Color.WHITE, "WorldEdit", Selector.SECOND));
|
||||||
+ Phrase.build(
|
|
||||||
Phrase.STATUS_INTEGRATION, Color.WHITE, "WorldEdit", Selector.SECOND));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
int consumerCount = 0;
|
int consumerCount = 0;
|
||||||
int currentConsumerSize = Process.getCurrentConsumerSize();
|
int currentConsumerSize = Process.getCurrentConsumerSize();
|
||||||
if (currentConsumerSize == 0) {
|
if (currentConsumerSize == 0) {
|
||||||
|
|
||||||
consumerCount = Consumer.getConsumerSize(0) + Consumer.getConsumerSize(1);
|
consumerCount = Consumer.getConsumerSize(0) + Consumer.getConsumerSize(1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int consumerId = (Consumer.currentConsumer == 1) ? 1 : 0;
|
int consumerId = (Consumer.currentConsumer == 1) ? 1 : 0;
|
||||||
consumerCount = Consumer.getConsumerSize(consumerId) + currentConsumerSize;
|
consumerCount = Consumer.getConsumerSize(consumerId) + currentConsumerSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (consumerCount >= 1 && (player instanceof Player)) {
|
if (consumerCount >= 1 && (player instanceof Player)) {
|
||||||
|
|
||||||
if (Config.getConfig(((Player) player).getWorld()).PLAYER_COMMANDS) {
|
if (Config.getConfig(((Player) player).getWorld()).PLAYER_COMMANDS) {
|
||||||
|
|
||||||
consumerCount = consumerCount - 1;
|
consumerCount = consumerCount - 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player,
|
||||||
player,
|
Color.DARK_AQUA + Phrase.build(Phrase.STATUS_CONSUMER, Color.WHITE,
|
||||||
Color.DARK_AQUA
|
String.format("%,d", consumerCount),
|
||||||
+ Phrase.build(
|
(consumerCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
Phrase.STATUS_CONSUMER,
|
|
||||||
Color.WHITE,
|
|
||||||
String.format("%,d", consumerCount),
|
|
||||||
(consumerCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String cpuInfo = "";
|
String cpuInfo = "";
|
||||||
if (ConfigHandler.processorInfo != null) {
|
if (ConfigHandler.processorInfo != null) {
|
||||||
String modelName = ConfigHandler.processorInfo
|
|
||||||
.getProcessorIdentifier()
|
String modelName = ConfigHandler.processorInfo.getProcessorIdentifier().getName();
|
||||||
.getName();
|
|
||||||
if (modelName.contains(" CPU")) {
|
if (modelName.contains(" CPU")) {
|
||||||
|
|
||||||
String[] split = modelName.split(" CPU")[0].split(" ");
|
String[] split = modelName.split(" CPU")[0].split(" ");
|
||||||
modelName = split[split.length - 1];
|
modelName = split[split.length - 1];
|
||||||
|
|
||||||
} else if (modelName.contains(" Processor")) {
|
} else if (modelName.contains(" Processor")) {
|
||||||
|
|
||||||
String[] split = modelName.split(" Processor")[0].split(" ");
|
String[] split = modelName.split(" Processor")[0].split(" ");
|
||||||
modelName = split[split.length - 1];
|
modelName = split[split.length - 1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String cpuSpeed = String.valueOf(ConfigHandler.processorInfo.getMaxFreq());
|
String cpuSpeed = String.valueOf(ConfigHandler.processorInfo.getMaxFreq());
|
||||||
cpuSpeed = String.format("%.2f", Long.valueOf(cpuSpeed) / 1000000000.0);
|
cpuSpeed = String.format("%.2f", Long.valueOf(cpuSpeed) / 1000000000.0);
|
||||||
cpuInfo = "x" + Runtime.getRuntime().availableProcessors() + " " + cpuSpeed + "GHz "
|
cpuInfo = "x" + Runtime.getRuntime().availableProcessors() + " " + cpuSpeed + "GHz "
|
||||||
+ modelName + ".";
|
+ modelName + ".";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
cpuInfo = "x" + Runtime.getRuntime().availableProcessors() + " "
|
cpuInfo = "x" + Runtime.getRuntime().availableProcessors() + " "
|
||||||
+ Phrase.build(Phrase.CPU_CORES);
|
+ Phrase.build(Phrase.CPU_CORES);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mb = 1024 * 1024;
|
int mb = 1024 * 1024;
|
||||||
Runtime runtime = Runtime.getRuntime();
|
Runtime runtime = Runtime.getRuntime();
|
||||||
String usedRAM = String.format(
|
String usedRAM = String.format("%.2f",
|
||||||
"%.2f", Double.valueOf((runtime.totalMemory() - runtime.freeMemory()) / mb) / 1000.0);
|
Double.valueOf((runtime.totalMemory() - runtime.freeMemory()) / mb) / 1000.0);
|
||||||
String totalRAM = String.format("%.2f", Double.valueOf(runtime.maxMemory() / mb) / 1000.0);
|
String totalRAM = String.format("%.2f", Double.valueOf(runtime.maxMemory() / mb) / 1000.0);
|
||||||
String systemInformation = Phrase.build(Phrase.RAM_STATS, usedRAM, totalRAM);
|
String systemInformation = Phrase.build(Phrase.RAM_STATS, usedRAM, totalRAM);
|
||||||
if (cpuInfo.length() > 0) {
|
if (cpuInfo.length() > 0) {
|
||||||
|
|
||||||
systemInformation = cpuInfo + " (" + systemInformation + ")";
|
systemInformation = cpuInfo + " (" + systemInformation + ")";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player,
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + Phrase.build(Phrase.STATUS_SYSTEM, Color.WHITE, systemInformation));
|
Color.DARK_AQUA + Phrase.build(Phrase.STATUS_SYSTEM, Color.WHITE, systemInformation));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions.sendMessage(player, Color.DARK_AQUA + "Website: " + Color.WHITE +
|
// Functions.sendMessage(player, Color.DARK_AQUA + "Website: " + Color.WHITE +
|
||||||
// "www.coreprotect.net/updates/");
|
// "www.coreprotect.net/updates/");
|
||||||
|
|
||||||
// Functions.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.LINK_DISCORD, Color.WHITE +
|
// Functions.sendMessage(player, Color.DARK_AQUA +
|
||||||
|
// Phrase.build(Phrase.LINK_DISCORD, Color.WHITE +
|
||||||
// "www.coreprotect.net/discord/").replaceFirst(":", ":" + Color.WHITE));
|
// "www.coreprotect.net/discord/").replaceFirst(":", ":" + Color.WHITE));
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(player, Color.DARK_AQUA
|
||||||
player,
|
+ Phrase.build(Phrase.LINK_DISCORD, Color.WHITE, "www.coreprotect.net/discord/"));
|
||||||
Color.DARK_AQUA
|
Chat.sendMessage(player, Color.DARK_AQUA
|
||||||
+ Phrase.build(Phrase.LINK_DISCORD, Color.WHITE, "www.coreprotect.net/discord/"));
|
+ Phrase.build(Phrase.LINK_PATREON, Color.WHITE, "www.patreon.com/coreprotect/"));
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
|
||||||
Color.DARK_AQUA
|
|
||||||
+ Phrase.build(Phrase.LINK_PATREON, Color.WHITE, "www.patreon.com/coreprotect/"));
|
|
||||||
|
|
||||||
if (player.isOp() && alert.get(player.getName()) == null) {
|
if (player.isOp() && alert.get(player.getName()) == null) {
|
||||||
|
|
||||||
alert.put(player.getName(), true);
|
alert.put(player.getName(), true);
|
||||||
|
|
||||||
if (instance.getServer().getPluginManager().getPlugin("CoreEdit") == null) {
|
if (instance.getServer().getPluginManager().getPlugin("CoreEdit") == null) {
|
||||||
|
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Functions.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA + "Recommended Plugin " + Color.WHITE + "-----");
|
* Functions.sendMessage(player, Color.WHITE + "----- " + Color.DARK_AQUA +
|
||||||
Functions.sendMessage(player, Color.DARK_AQUA + "Notice: " + Color.WHITE + "Enjoy CoreProtect? Check out CoreEdit!");
|
* "Recommended Plugin " + Color.WHITE + "-----"); Functions.sendMessage(player,
|
||||||
Functions.sendMessage(player, Color.DARK_AQUA + "Download: " + Color.WHITE + "www.coreedit.net/download/");
|
* Color.DARK_AQUA + "Notice: " + Color.WHITE +
|
||||||
*/
|
* "Enjoy CoreProtect? Check out CoreEdit!"); Functions.sendMessage(player,
|
||||||
|
* Color.DARK_AQUA + "Download: " + Color.WHITE + "www.coreedit.net/download/");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Runnable runnable = new BasicThread();
|
Runnable runnable = new BasicThread();
|
||||||
Thread thread = new Thread(runnable);
|
Thread thread = new Thread(runnable);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,94 +19,97 @@ import org.bukkit.util.StringUtil;
|
|||||||
|
|
||||||
public class TabHandler implements TabCompleter {
|
public class TabHandler implements TabCompleter {
|
||||||
|
|
||||||
// private static String[] COMMANDS = new String[] { "help", "inspect", "rollback", "restore", "lookup", "purge",
|
// private static String[] COMMANDS = new String[] { "help", "inspect",
|
||||||
|
// "rollback", "restore", "lookup", "purge",
|
||||||
// "reload", "status", "near", "undo" }; // max 10!
|
// "reload", "status", "near", "undo" }; // max 10!
|
||||||
private static String[] HELP = new String[] {
|
private static String[] HELP = new String[] { "inspect", "rollback", "restore", "lookup", "purge", "teleport",
|
||||||
"inspect",
|
"status", "params", "users", "time", "radius", "action", "include", "exclude" };
|
||||||
"rollback",
|
private static String[] PARAMS = new String[] { "user:", "time:", "radius:", "action:", "include:", "exclude:",
|
||||||
"restore",
|
"#container" };
|
||||||
"lookup",
|
private static String[] ACTIONS = new String[] { "block", "+block", "-block", "click", "kill", "+container",
|
||||||
"purge",
|
"-container", "container", "chat", "command", "+inventory", "-inventory", "inventory", "item", "+item",
|
||||||
"teleport",
|
"-item", "sign", "session", "+session", "-session", "username" };
|
||||||
"status",
|
private static String[] NUMBERS = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
"params",
|
private static String[] TIMES = new String[] { "w", "d", "h", "m", "s" };
|
||||||
"users",
|
|
||||||
"time",
|
|
||||||
"radius",
|
|
||||||
"action",
|
|
||||||
"include",
|
|
||||||
"exclude"
|
|
||||||
};
|
|
||||||
private static String[] PARAMS =
|
|
||||||
new String[] {"user:", "time:", "radius:", "action:", "include:", "exclude:", "#container"};
|
|
||||||
private static String[] ACTIONS = new String[] {
|
|
||||||
"block",
|
|
||||||
"+block",
|
|
||||||
"-block",
|
|
||||||
"click",
|
|
||||||
"kill",
|
|
||||||
"+container",
|
|
||||||
"-container",
|
|
||||||
"container",
|
|
||||||
"chat",
|
|
||||||
"command",
|
|
||||||
"+inventory",
|
|
||||||
"-inventory",
|
|
||||||
"inventory",
|
|
||||||
"item",
|
|
||||||
"+item",
|
|
||||||
"-item",
|
|
||||||
"sign",
|
|
||||||
"session",
|
|
||||||
"+session",
|
|
||||||
"-session",
|
|
||||||
"username"
|
|
||||||
};
|
|
||||||
private static String[] NUMBERS = new String[] {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
|
|
||||||
private static String[] TIMES = new String[] {"w", "d", "h", "m", "s"};
|
|
||||||
private static ArrayList<String> materials = null;
|
private static ArrayList<String> materials = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
|
||||||
if (!(sender instanceof Player) || args.length == 0) {
|
if (!(sender instanceof Player) || args.length == 0) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
|
|
||||||
String argument = args[0].toLowerCase(Locale.ROOT);
|
String argument = args[0].toLowerCase(Locale.ROOT);
|
||||||
List<String> completions = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
if (sender.hasPermission("coreprotect.help")) {
|
if (sender.hasPermission("coreprotect.help")) {
|
||||||
|
|
||||||
completions.add("help");
|
completions.add("help");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("coreprotect.inspect")) {
|
if (sender.hasPermission("coreprotect.inspect")) {
|
||||||
|
|
||||||
completions.add("inspect");
|
completions.add("inspect");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("coreprotect.rollback")) {
|
if (sender.hasPermission("coreprotect.rollback")) {
|
||||||
|
|
||||||
completions.add("rollback");
|
completions.add("rollback");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("coreprotect.restore")) {
|
if (sender.hasPermission("coreprotect.restore")) {
|
||||||
|
|
||||||
completions.add("restore");
|
completions.add("restore");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("coreprotect.lookup")) {
|
if (sender.hasPermission("coreprotect.lookup")) {
|
||||||
|
|
||||||
completions.add("lookup");
|
completions.add("lookup");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("coreprotect.purge")) {
|
if (sender.hasPermission("coreprotect.purge")) {
|
||||||
|
|
||||||
completions.add("purge");
|
completions.add("purge");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("coreprotect.reload")) {
|
if (sender.hasPermission("coreprotect.reload")) {
|
||||||
|
|
||||||
completions.add("reload");
|
completions.add("reload");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("coreprotect.status")) {
|
if (sender.hasPermission("coreprotect.status")) {
|
||||||
|
|
||||||
completions.add("status");
|
completions.add("status");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("coreprotect.lookup.near")) {
|
if (sender.hasPermission("coreprotect.lookup.near")) {
|
||||||
|
|
||||||
completions.add("near");
|
completions.add("near");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("coreprotect.restore")) {
|
if (sender.hasPermission("coreprotect.restore")) {
|
||||||
|
|
||||||
completions.add("undo");
|
completions.add("undo");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringUtil.copyPartialMatches(argument, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(argument, completions, new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
} else if (args.length > 1) {
|
} else if (args.length > 1) {
|
||||||
|
|
||||||
String argument0 = args[0].toLowerCase(Locale.ROOT);
|
String argument0 = args[0].toLowerCase(Locale.ROOT);
|
||||||
String argument1 = args[1].toLowerCase(Locale.ROOT);
|
String argument1 = args[1].toLowerCase(Locale.ROOT);
|
||||||
String currentArg = args[args.length - 1].toLowerCase(Locale.ROOT).trim();
|
String currentArg = args[args.length - 1].toLowerCase(Locale.ROOT).trim();
|
||||||
@@ -126,416 +129,547 @@ public class TabHandler implements TabCompleter {
|
|||||||
boolean pageLookup = false;
|
boolean pageLookup = false;
|
||||||
|
|
||||||
if (ConfigHandler.lookupType.get(sender.getName()) != null
|
if (ConfigHandler.lookupType.get(sender.getName()) != null
|
||||||
&& ConfigHandler.lookupPage.get(sender.getName()) != null) {
|
&& ConfigHandler.lookupPage.get(sender.getName()) != null)
|
||||||
|
{
|
||||||
|
|
||||||
pageLookup = true;
|
pageLookup = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
|
||||||
String arg = args[i].toLowerCase(Locale.ROOT);
|
String arg = args[i].toLowerCase(Locale.ROOT);
|
||||||
if (arg.equals("#container")) {
|
if (arg.equals("#container")) {
|
||||||
|
|
||||||
hasContainer = true;
|
hasContainer = true;
|
||||||
|
|
||||||
} else if (arg.equals("#count") || arg.equals("#sum")) {
|
} else if (arg.equals("#count") || arg.equals("#sum")) {
|
||||||
|
|
||||||
hasCount = true;
|
hasCount = true;
|
||||||
|
|
||||||
} else if (arg.equals("#preview")) {
|
} else if (arg.equals("#preview")) {
|
||||||
|
|
||||||
hasPreview = true;
|
hasPreview = true;
|
||||||
|
|
||||||
} else if ((!arg.contains(":") && !args[i - 1].contains(":") && args.length > (i + 1))
|
} else if ((!arg.contains(":") && !args[i - 1].contains(":") && args.length > (i + 1))
|
||||||
|| arg.contains("u:")
|
|| arg.contains("u:") || arg.contains("user:") || arg.contains("users:") || arg.contains("p:"))
|
||||||
|| arg.contains("user:")
|
{
|
||||||
|| arg.contains("users:")
|
|
||||||
|| arg.contains("p:")) {
|
|
||||||
hasUser = true;
|
hasUser = true;
|
||||||
|
|
||||||
} else if (arg.contains("page:")) {
|
} else if (arg.contains("page:")) {
|
||||||
|
|
||||||
hasPage = true;
|
hasPage = true;
|
||||||
|
|
||||||
} else if (arg.contains("a:") || arg.contains("action:")) {
|
} else if (arg.contains("a:") || arg.contains("action:")) {
|
||||||
|
|
||||||
hasAction = true;
|
hasAction = true;
|
||||||
} else if (arg.contains("i:")
|
|
||||||
|| arg.contains("include:")
|
} else if (arg.contains("i:") || arg.contains("include:") || arg.contains("item:")
|
||||||
|| arg.contains("item:")
|
|| arg.contains("items:") || arg.contains("b:") || arg.contains("block:")
|
||||||
|| arg.contains("items:")
|
|| arg.contains("blocks:"))
|
||||||
|| arg.contains("b:")
|
{
|
||||||
|| arg.contains("block:")
|
|
||||||
|| arg.contains("blocks:")) {
|
|
||||||
hasInclude = true;
|
hasInclude = true;
|
||||||
|
|
||||||
} else if (arg.contains("t:") || arg.contains("time:")) {
|
} else if (arg.contains("t:") || arg.contains("time:")) {
|
||||||
|
|
||||||
hasTime = true;
|
hasTime = true;
|
||||||
|
|
||||||
} else if (arg.contains("e:") || arg.contains("exclude:")) {
|
} else if (arg.contains("e:") || arg.contains("exclude:")) {
|
||||||
|
|
||||||
hasExclude = true;
|
hasExclude = true;
|
||||||
|
|
||||||
} else if (arg.contains("r:") || arg.contains("radius:")) {
|
} else if (arg.contains("r:") || arg.contains("radius:")) {
|
||||||
|
|
||||||
hasRadius = true;
|
hasRadius = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasContainer) {
|
if (!hasContainer) {
|
||||||
|
|
||||||
if (ConfigHandler.lookupType.get(sender.getName()) != null) {
|
if (ConfigHandler.lookupType.get(sender.getName()) != null) {
|
||||||
|
|
||||||
int lookupType = ConfigHandler.lookupType.get(sender.getName());
|
int lookupType = ConfigHandler.lookupType.get(sender.getName());
|
||||||
if (lookupType == 1) {
|
if (lookupType == 1) {
|
||||||
|
|
||||||
validContainer = true;
|
validContainer = true;
|
||||||
|
|
||||||
} else if (lookupType == 5) {
|
} else if (lookupType == 5) {
|
||||||
|
|
||||||
if (ConfigHandler.lookupUlist.get(sender.getName()).contains("#container")) {
|
if (ConfigHandler.lookupUlist.get(sender.getName()).contains("#container")) {
|
||||||
|
|
||||||
validContainer = true;
|
validContainer = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((lastArg.equals("a:") || lastArg.equals("action:"))
|
if ((lastArg.equals("a:") || lastArg.equals("action:")) && (sender.hasPermission("coreprotect.lookup")
|
||||||
&& (sender.hasPermission("coreprotect.lookup")
|
|| sender.hasPermission("coreprotect.rollback") || sender.hasPermission("coreprotect.restore")))
|
||||||
|| sender.hasPermission("coreprotect.rollback")
|
{
|
||||||
|| sender.hasPermission("coreprotect.restore"))) {
|
|
||||||
List<String> completions = new ArrayList<>(Arrays.asList(ACTIONS));
|
List<String> completions = new ArrayList<>(Arrays.asList(ACTIONS));
|
||||||
return StringUtil.copyPartialMatches(currentArg, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(currentArg, completions, new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
} else if ((currentArg.startsWith("a:") || currentArg.startsWith("action:"))
|
} else if ((currentArg.startsWith("a:") || currentArg.startsWith("action:"))
|
||||||
&& (sender.hasPermission("coreprotect.lookup")
|
&& (sender.hasPermission("coreprotect.lookup") || sender.hasPermission("coreprotect.rollback")
|
||||||
|| sender.hasPermission("coreprotect.rollback")
|
|| sender.hasPermission("coreprotect.restore")))
|
||||||
|| sender.hasPermission("coreprotect.restore"))) {
|
{
|
||||||
|
|
||||||
String arg = "";
|
String arg = "";
|
||||||
String[] split = currentArg.split(":", 2);
|
String[] split = currentArg.split(":", 2);
|
||||||
String filter = split[0] + ":";
|
String filter = split[0] + ":";
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
|
|
||||||
arg = split[1];
|
arg = split[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> completions = new ArrayList<>(Arrays.asList(ACTIONS));
|
List<String> completions = new ArrayList<>(Arrays.asList(ACTIONS));
|
||||||
for (int index = 0; index < completions.size(); index++) {
|
for (int index = 0; index < completions.size(); index++) {
|
||||||
|
|
||||||
completions.set(index, filter + completions.get(index));
|
completions.set(index, filter + completions.get(index));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringUtil.copyPartialMatches(filter + arg, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(filter + arg, completions, new ArrayList<>(completions.size()));
|
||||||
} else if ((lastArg.equals("u:")
|
|
||||||
|| lastArg.equals("user:")
|
} else if ((lastArg.equals("u:") || lastArg.equals("user:") || lastArg.equals("users:")
|
||||||
|| lastArg.equals("users:")
|
|| lastArg.equals("p:"))
|
||||||
|| lastArg.equals("p:"))
|
&& (sender.hasPermission("coreprotect.lookup") || sender.hasPermission("coreprotect.rollback")
|
||||||
&& (sender.hasPermission("coreprotect.lookup")
|
|| sender.hasPermission("coreprotect.restore")))
|
||||||
|| sender.hasPermission("coreprotect.rollback")
|
{
|
||||||
|| sender.hasPermission("coreprotect.restore"))) {
|
|
||||||
return null;
|
return null;
|
||||||
} else if ((currentArg.startsWith("u:")
|
|
||||||
|| currentArg.startsWith("user:")
|
} else if ((currentArg.startsWith("u:") || currentArg.startsWith("user:") || currentArg.startsWith("users:")
|
||||||
|| currentArg.startsWith("users:")
|
|| currentArg.startsWith("p:"))
|
||||||
|| currentArg.startsWith("p:"))
|
&& (sender.hasPermission("coreprotect.lookup") || sender.hasPermission("coreprotect.rollback")
|
||||||
&& (sender.hasPermission("coreprotect.lookup")
|
|| sender.hasPermission("coreprotect.restore")))
|
||||||
|| sender.hasPermission("coreprotect.rollback")
|
{
|
||||||
|| sender.hasPermission("coreprotect.restore"))) {
|
|
||||||
String arg = "";
|
String arg = "";
|
||||||
String[] split = currentArg.split(":", 2);
|
String[] split = currentArg.split(":", 2);
|
||||||
String filter = split[0] + ":";
|
String filter = split[0] + ":";
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
|
|
||||||
arg = split[1];
|
arg = split[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> completions =
|
List<String> completions = Bukkit.getOnlinePlayers().stream().map(Player::getName)
|
||||||
Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
for (int index = 0; index < completions.size(); index++) {
|
for (int index = 0; index < completions.size(); index++) {
|
||||||
|
|
||||||
completions.set(index, filter + completions.get(index));
|
completions.set(index, filter + completions.get(index));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringUtil.copyPartialMatches(filter + arg, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(filter + arg, completions, new ArrayList<>(completions.size()));
|
||||||
} else if ((lastArg.equals("t:")
|
|
||||||
|| lastArg.equals("time:")
|
} else if ((lastArg.equals("t:") || lastArg.equals("time:") || currentArg.startsWith("t:")
|
||||||
|| currentArg.startsWith("t:")
|
|| currentArg.startsWith("time:"))
|
||||||
|| currentArg.startsWith("time:"))
|
&& (sender.hasPermission("coreprotect.lookup") || sender.hasPermission("coreprotect.rollback")
|
||||||
&& (sender.hasPermission("coreprotect.lookup")
|
|
||||||
|| sender.hasPermission("coreprotect.rollback")
|
|
||||||
|| sender.hasPermission("coreprotect.restore")
|
|| sender.hasPermission("coreprotect.restore")
|
||||||
|| sender.hasPermission("coreprotect.purge"))) {
|
|| sender.hasPermission("coreprotect.purge")))
|
||||||
|
{
|
||||||
|
|
||||||
String filter = lastArg;
|
String filter = lastArg;
|
||||||
String arg = "";
|
String arg = "";
|
||||||
if (currentArg.contains(":")) {
|
if (currentArg.contains(":")) {
|
||||||
|
|
||||||
String[] split = currentArg.split(":", 2);
|
String[] split = currentArg.split(":", 2);
|
||||||
filter = split[0] + ":";
|
filter = split[0] + ":";
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
|
|
||||||
arg = split[1];
|
arg = split[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
filter = "";
|
filter = "";
|
||||||
arg = currentArg;
|
arg = currentArg;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> completions = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
if (arg.chars().allMatch(Character::isDigit)) {
|
if (arg.chars().allMatch(Character::isDigit)) {
|
||||||
|
|
||||||
boolean addNumbers = true;
|
boolean addNumbers = true;
|
||||||
if (currentArg.length() > 0) {
|
if (currentArg.length() > 0) {
|
||||||
|
|
||||||
char lastChar = currentArg.charAt(currentArg.length() - 1);
|
char lastChar = currentArg.charAt(currentArg.length() - 1);
|
||||||
if (Character.isDigit(lastChar)) {
|
if (Character.isDigit(lastChar)) {
|
||||||
|
|
||||||
completions.addAll(Arrays.asList(TIMES));
|
completions.addAll(Arrays.asList(TIMES));
|
||||||
addNumbers = false;
|
addNumbers = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addNumbers) {
|
if (addNumbers) {
|
||||||
|
|
||||||
completions.addAll(Arrays.asList(NUMBERS));
|
completions.addAll(Arrays.asList(NUMBERS));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completions = new ArrayList<>(completions);
|
completions = new ArrayList<>(completions);
|
||||||
for (int index = 0; index < completions.size(); index++) {
|
for (int index = 0; index < completions.size(); index++) {
|
||||||
|
|
||||||
completions.set(index, filter + arg + completions.get(index));
|
completions.set(index, filter + arg + completions.get(index));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringUtil.copyPartialMatches(filter + arg, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(filter + arg, completions, new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
} else if ((lastArg.equals("page:") || currentArg.startsWith("page:"))
|
} else if ((lastArg.equals("page:") || currentArg.startsWith("page:"))
|
||||||
&& (sender.hasPermission("coreprotect.lookup")
|
&& (sender.hasPermission("coreprotect.lookup") || sender.hasPermission("coreprotect.lookup.near")
|
||||||
|| sender.hasPermission("coreprotect.lookup.near")
|
|| sender.hasPermission("coreprotect.inspect")))
|
||||||
|| sender.hasPermission("coreprotect.inspect"))) {
|
{
|
||||||
|
|
||||||
String filter = lastArg;
|
String filter = lastArg;
|
||||||
String arg = "";
|
String arg = "";
|
||||||
if (currentArg.contains(":")) {
|
if (currentArg.contains(":")) {
|
||||||
|
|
||||||
String[] split = currentArg.split(":", 2);
|
String[] split = currentArg.split(":", 2);
|
||||||
filter = split[0] + ":";
|
filter = split[0] + ":";
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
|
|
||||||
arg = split[1];
|
arg = split[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
filter = "";
|
filter = "";
|
||||||
arg = currentArg;
|
arg = currentArg;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg.chars().allMatch(Character::isDigit)) {
|
if (arg.chars().allMatch(Character::isDigit)) {
|
||||||
|
|
||||||
List<String> completions = new ArrayList<>(Arrays.asList(NUMBERS));
|
List<String> completions = new ArrayList<>(Arrays.asList(NUMBERS));
|
||||||
if (arg.length() < 1) {
|
if (arg.length() < 1) {
|
||||||
|
|
||||||
for (int index = 0; index < completions.size(); index++) {
|
for (int index = 0; index < completions.size(); index++) {
|
||||||
|
|
||||||
completions.set(index, filter + arg + completions.get(index));
|
completions.set(index, filter + arg + completions.get(index));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg.length() == 0) {
|
if (arg.length() == 0) {
|
||||||
|
|
||||||
completions.remove(0);
|
completions.remove(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return StringUtil.copyPartialMatches(
|
|
||||||
filter + arg, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(filter + arg, completions,
|
||||||
|
new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if ((lastArg.equals("r:")
|
|
||||||
|| lastArg.equals("radius:")
|
} else if ((lastArg.equals("r:") || lastArg.equals("radius:") || currentArg.startsWith("r:")
|
||||||
|| currentArg.startsWith("r:")
|
|| currentArg.startsWith("radius:"))
|
||||||
|| currentArg.startsWith("radius:"))
|
&& (sender.hasPermission("coreprotect.lookup") || sender.hasPermission("coreprotect.rollback")
|
||||||
&& (sender.hasPermission("coreprotect.lookup")
|
|
||||||
|| sender.hasPermission("coreprotect.rollback")
|
|
||||||
|| sender.hasPermission("coreprotect.restore")
|
|| sender.hasPermission("coreprotect.restore")
|
||||||
|| sender.hasPermission("coreprotect.purge"))) {
|
|| sender.hasPermission("coreprotect.purge")))
|
||||||
|
{
|
||||||
|
|
||||||
String filter = lastArg;
|
String filter = lastArg;
|
||||||
String arg = "";
|
String arg = "";
|
||||||
if (currentArg.contains(":")) {
|
if (currentArg.contains(":")) {
|
||||||
|
|
||||||
String[] split = currentArg.split(":", 2);
|
String[] split = currentArg.split(":", 2);
|
||||||
filter = split[0] + ":";
|
filter = split[0] + ":";
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
|
|
||||||
arg = split[1];
|
arg = split[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
filter = "";
|
filter = "";
|
||||||
arg = currentArg;
|
arg = currentArg;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!argument0.equals("purge") && arg.chars().allMatch(Character::isDigit)) {
|
if (!argument0.equals("purge") && arg.chars().allMatch(Character::isDigit)) {
|
||||||
|
|
||||||
List<String> completions = new ArrayList<>(Arrays.asList(NUMBERS));
|
List<String> completions = new ArrayList<>(Arrays.asList(NUMBERS));
|
||||||
if (arg.length() < 2) {
|
if (arg.length() < 2) {
|
||||||
|
|
||||||
for (int index = 0; index < completions.size(); index++) {
|
for (int index = 0; index < completions.size(); index++) {
|
||||||
|
|
||||||
completions.set(index, filter + arg + completions.get(index));
|
completions.set(index, filter + arg + completions.get(index));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return StringUtil.copyPartialMatches(
|
|
||||||
filter + arg, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(filter + arg, completions,
|
||||||
|
new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
} else if (argument0.equals("purge") || arg.startsWith("#")) {
|
} else if (argument0.equals("purge") || arg.startsWith("#")) {
|
||||||
|
|
||||||
ArrayList<String> params = new ArrayList<>();
|
ArrayList<String> params = new ArrayList<>();
|
||||||
params.add("#global");
|
params.add("#global");
|
||||||
if (!argument0.equals("purge")
|
if (!argument0.equals("purge")
|
||||||
&& sender.getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
&& sender.getServer().getPluginManager().getPlugin("WorldEdit") != null)
|
||||||
|
{
|
||||||
|
|
||||||
params.add("#worldedit");
|
params.add("#worldedit");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<World> worlds = sender.getServer().getWorlds();
|
List<World> worlds = sender.getServer().getWorlds();
|
||||||
for (World world : worlds) {
|
for (World world : worlds) {
|
||||||
|
|
||||||
params.add("#" + world.getName());
|
params.add("#" + world.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> completions = new ArrayList<>(params);
|
List<String> completions = new ArrayList<>(params);
|
||||||
for (int index = 0; index < completions.size(); index++) {
|
for (int index = 0; index < completions.size(); index++) {
|
||||||
|
|
||||||
completions.set(index, filter + completions.get(index));
|
completions.set(index, filter + completions.get(index));
|
||||||
|
|
||||||
}
|
}
|
||||||
return StringUtil.copyPartialMatches(
|
|
||||||
filter + arg, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(filter + arg, completions,
|
||||||
|
new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if ((sender.hasPermission("coreprotect.lookup")
|
|
||||||
|| sender.hasPermission("coreprotect.rollback")
|
} else if ((sender.hasPermission("coreprotect.lookup") || sender.hasPermission("coreprotect.rollback")
|
||||||
|| sender.hasPermission("coreprotect.restore"))
|
|| sender.hasPermission("coreprotect.restore"))
|
||||||
&& (lastArg.equals("i:")
|
&& (lastArg.equals("i:") || lastArg.equals("include:") || lastArg.equals("item:")
|
||||||
|| lastArg.equals("include:")
|
|| lastArg.equals("items:") || lastArg.equals("b:") || lastArg.equals("block:")
|
||||||
|| lastArg.equals("item:")
|
|| lastArg.equals("blocks:") || currentArg.startsWith("i:")
|
||||||
|| lastArg.equals("items:")
|
|| currentArg.startsWith("include:") || currentArg.startsWith("item:")
|
||||||
|| lastArg.equals("b:")
|
|| currentArg.startsWith("items:") || currentArg.startsWith("b:")
|
||||||
|| lastArg.equals("block:")
|
|| currentArg.startsWith("block:") || currentArg.startsWith("blocks:")
|
||||||
|| lastArg.equals("blocks:")
|
|| lastArg.equals("e:") || lastArg.equals("exclude:") || currentArg.startsWith("e:")
|
||||||
|| currentArg.startsWith("i:")
|
|| currentArg.startsWith("exclude:")))
|
||||||
|| currentArg.startsWith("include:")
|
{
|
||||||
|| currentArg.startsWith("item:")
|
|
||||||
|| currentArg.startsWith("items:")
|
|
||||||
|| currentArg.startsWith("b:")
|
|
||||||
|| currentArg.startsWith("block:")
|
|
||||||
|| currentArg.startsWith("blocks:")
|
|
||||||
|| lastArg.equals("e:")
|
|
||||||
|| lastArg.equals("exclude:")
|
|
||||||
|| currentArg.startsWith("e:")
|
|
||||||
|| currentArg.startsWith("exclude:"))) {
|
|
||||||
String filter = lastArg;
|
String filter = lastArg;
|
||||||
String arg = "";
|
String arg = "";
|
||||||
if (currentArg.contains(":")) {
|
if (currentArg.contains(":")) {
|
||||||
|
|
||||||
String[] split = currentArg.split(":", 2);
|
String[] split = currentArg.split(":", 2);
|
||||||
filter = split[0] + ":";
|
filter = split[0] + ":";
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
|
|
||||||
arg = split[1];
|
arg = split[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
filter = "";
|
filter = "";
|
||||||
arg = currentArg;
|
arg = currentArg;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (materials == null) {
|
if (materials == null) {
|
||||||
|
|
||||||
List<Material> addList = Arrays.asList(Material.ARMOR_STAND);
|
List<Material> addList = Arrays.asList(Material.ARMOR_STAND);
|
||||||
List<Material> excludeList = Arrays.asList();
|
List<Material> excludeList = Arrays.asList();
|
||||||
Set<String> materialList = new HashSet<>();
|
Set<String> materialList = new HashSet<>();
|
||||||
|
|
||||||
Material[] materialValues = Material.values();
|
Material[] materialValues = Material.values();
|
||||||
for (Material material : materialValues) {
|
for (Material material : materialValues) {
|
||||||
|
|
||||||
if (material.isBlock() || material.isItem()) {
|
if (material.isBlock() || material.isItem()) {
|
||||||
|
|
||||||
materialList.add(material.name().toLowerCase(Locale.ROOT));
|
materialList.add(material.name().toLowerCase(Locale.ROOT));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Material exclude : excludeList) {
|
for (Material exclude : excludeList) {
|
||||||
|
|
||||||
materialList.remove(exclude.name().toLowerCase(Locale.ROOT));
|
materialList.remove(exclude.name().toLowerCase(Locale.ROOT));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Material add : addList) {
|
for (Material add : addList) {
|
||||||
|
|
||||||
materialList.add(add.name().toLowerCase(Locale.ROOT));
|
materialList.add(add.name().toLowerCase(Locale.ROOT));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add custom tags
|
// add custom tags
|
||||||
for (String tag : CommandHandler.getTags().keySet()) {
|
for (String tag : CommandHandler.getTags().keySet()) {
|
||||||
|
|
||||||
materialList.add(tag);
|
materialList.add(tag);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
materials = new ArrayList<>(materialList);
|
materials = new ArrayList<>(materialList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> completions = new ArrayList<>(materials);
|
List<String> completions = new ArrayList<>(materials);
|
||||||
for (int index = 0; index < completions.size(); index++) {
|
for (int index = 0; index < completions.size(); index++) {
|
||||||
|
|
||||||
completions.set(index, filter + completions.get(index));
|
completions.set(index, filter + completions.get(index));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringUtil.copyPartialMatches(filter + arg, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(filter + arg, completions, new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
|
|
||||||
if (argument0.equals("help") && sender.hasPermission("coreprotect.help")) {
|
if (argument0.equals("help") && sender.hasPermission("coreprotect.help")) {
|
||||||
|
|
||||||
List<String> completions = new ArrayList<>(Arrays.asList(HELP));
|
List<String> completions = new ArrayList<>(Arrays.asList(HELP));
|
||||||
return StringUtil.copyPartialMatches(argument1, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(argument1, completions, new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
} else if (argument0.equals("purge") && sender.hasPermission("coreprotect.purge")) {
|
} else if (argument0.equals("purge") && sender.hasPermission("coreprotect.purge")) {
|
||||||
|
|
||||||
List<String> completions = new ArrayList<>(Arrays.asList("t:", "r:", "i:"));
|
List<String> completions = new ArrayList<>(Arrays.asList("t:", "r:", "i:"));
|
||||||
return StringUtil.copyPartialMatches(argument1, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(argument1, completions, new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
} else if ((sender.hasPermission("coreprotect.lookup")
|
} else if ((sender.hasPermission("coreprotect.lookup")
|
||||||
&& (argument0.equals("l") || argument0.equals("lookup")))
|
&& (argument0.equals("l") || argument0.equals("lookup")))
|
||||||
|| (sender.hasPermission("coreprotect.rollback")
|
|| (sender.hasPermission("coreprotect.rollback")
|
||||||
&& (argument0.equals("rollback") || argument0.equals("rb") || argument0.equals("ro")))
|
&& (argument0.equals("rollback") || argument0.equals("rb") || argument0.equals("ro")))
|
||||||
|| (sender.hasPermission("coreprotect.restore")
|
|| (sender.hasPermission("coreprotect.restore")
|
||||||
&& (argument0.equals("restore") || argument0.equals("rs") || argument0.equals("re")))) {
|
&& (argument0.equals("restore") || argument0.equals("rs") || argument0.equals("re"))))
|
||||||
List<String> completions = new ArrayList<>(filterParams(
|
{
|
||||||
true,
|
|
||||||
argument0,
|
List<String> completions = new ArrayList<>(filterParams(true, argument0, argument1, hasUser,
|
||||||
argument1,
|
hasAction, hasInclude, hasExclude, hasRadius, hasTime, hasContainer, hasCount, hasPreview,
|
||||||
hasUser,
|
pageLookup, validContainer));
|
||||||
hasAction,
|
|
||||||
hasInclude,
|
|
||||||
hasExclude,
|
|
||||||
hasRadius,
|
|
||||||
hasTime,
|
|
||||||
hasContainer,
|
|
||||||
hasCount,
|
|
||||||
hasPreview,
|
|
||||||
pageLookup,
|
|
||||||
validContainer));
|
|
||||||
completions.addAll(Bukkit.getOnlinePlayers().stream()
|
completions.addAll(Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(player ->
|
.filter(player -> player.getName().toLowerCase(Locale.ROOT).startsWith(argument1))
|
||||||
player.getName().toLowerCase(Locale.ROOT).startsWith(argument1))
|
.map(Player::getName).collect(Collectors.toList()));
|
||||||
.map(Player::getName)
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
return StringUtil.copyPartialMatches(argument1, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(argument1, completions, new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (args.length == 3 && argument0.equals("purge") && sender.hasPermission("coreprotect.purge")) {
|
} else if (args.length == 3 && argument0.equals("purge") && sender.hasPermission("coreprotect.purge")) {
|
||||||
|
|
||||||
if (argument1.startsWith("t:")) {
|
if (argument1.startsWith("t:")) {
|
||||||
|
|
||||||
List<String> completions = new ArrayList<>(Arrays.asList("r:", "i:"));
|
List<String> completions = new ArrayList<>(Arrays.asList("r:", "i:"));
|
||||||
return StringUtil.copyPartialMatches(
|
return StringUtil.copyPartialMatches(args[2].toLowerCase(Locale.ROOT), completions,
|
||||||
args[2].toLowerCase(Locale.ROOT), completions, new ArrayList<>(completions.size()));
|
new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
} else if (argument1.startsWith("r:") || argument1.startsWith("i:")) {
|
} else if (argument1.startsWith("r:") || argument1.startsWith("i:")) {
|
||||||
|
|
||||||
List<String> completions = new ArrayList<>(Arrays.asList("t:"));
|
List<String> completions = new ArrayList<>(Arrays.asList("t:"));
|
||||||
return StringUtil.copyPartialMatches(
|
return StringUtil.copyPartialMatches(args[2].toLowerCase(Locale.ROOT), completions,
|
||||||
args[2].toLowerCase(Locale.ROOT), completions, new ArrayList<>(completions.size()));
|
new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Arrays.asList("");
|
return Arrays.asList("");
|
||||||
|
|
||||||
} else if ((sender.hasPermission("coreprotect.lookup")
|
} else if ((sender.hasPermission("coreprotect.lookup")
|
||||||
&& (argument0.equals("l") || argument0.equals("lookup")))
|
&& (argument0.equals("l") || argument0.equals("lookup")))
|
||||||
|| (sender.hasPermission("coreprotect.rollback")
|
|| (sender.hasPermission("coreprotect.rollback")
|
||||||
&& (argument0.equals("rollback") || argument0.equals("rb") || argument0.equals("ro")))
|
&& (argument0.equals("rollback") || argument0.equals("rb") || argument0.equals("ro")))
|
||||||
|| (sender.hasPermission("coreprotect.restore")
|
|| (sender.hasPermission("coreprotect.restore")
|
||||||
&& (argument0.equals("restore") || argument0.equals("rs") || argument0.equals("re")))) {
|
&& (argument0.equals("restore") || argument0.equals("rs") || argument0.equals("re"))))
|
||||||
|
{
|
||||||
|
|
||||||
if ((!argument0.equals("l") && !argument0.equals("lookup")) || !hasPage) {
|
if ((!argument0.equals("l") && !argument0.equals("lookup")) || !hasPage) {
|
||||||
ArrayList<String> params = filterParams(
|
|
||||||
false,
|
ArrayList<String> params = filterParams(false, argument0, currentArg, hasUser, hasAction,
|
||||||
argument0,
|
hasInclude, hasExclude, hasRadius, hasTime, hasContainer, hasCount, hasPreview, pageLookup,
|
||||||
currentArg,
|
|
||||||
hasUser,
|
|
||||||
hasAction,
|
|
||||||
hasInclude,
|
|
||||||
hasExclude,
|
|
||||||
hasRadius,
|
|
||||||
hasTime,
|
|
||||||
hasContainer,
|
|
||||||
hasCount,
|
|
||||||
hasPreview,
|
|
||||||
pageLookup,
|
|
||||||
validContainer);
|
validContainer);
|
||||||
List<String> completions = new ArrayList<>(params);
|
List<String> completions = new ArrayList<>(params);
|
||||||
return StringUtil.copyPartialMatches(currentArg, completions, new ArrayList<>(completions.size()));
|
return StringUtil.copyPartialMatches(currentArg, completions, new ArrayList<>(completions.size()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Arrays.asList("");
|
return Arrays.asList("");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<String> filterParams(
|
private ArrayList<String> filterParams(boolean firstParam, String lastArgument, String argument, boolean hasUser,
|
||||||
boolean firstParam,
|
boolean hasAction, boolean hasInclude, boolean hasExclude, boolean hasRadius, boolean hasTime,
|
||||||
String lastArgument,
|
boolean hasContainer, boolean hasCount, boolean hasPreview, boolean pageLookup, boolean validContainer)
|
||||||
String argument,
|
{
|
||||||
boolean hasUser,
|
|
||||||
boolean hasAction,
|
|
||||||
boolean hasInclude,
|
|
||||||
boolean hasExclude,
|
|
||||||
boolean hasRadius,
|
|
||||||
boolean hasTime,
|
|
||||||
boolean hasContainer,
|
|
||||||
boolean hasCount,
|
|
||||||
boolean hasPreview,
|
|
||||||
boolean pageLookup,
|
|
||||||
boolean validContainer) {
|
|
||||||
ArrayList<String> params = new ArrayList<>();
|
ArrayList<String> params = new ArrayList<>();
|
||||||
for (String param : PARAMS) {
|
for (String param : PARAMS) {
|
||||||
|
|
||||||
if (param.equals("user:") && !hasUser) {
|
if (param.equals("user:") && !hasUser) {
|
||||||
|
|
||||||
params.add(param);
|
params.add(param);
|
||||||
|
|
||||||
} else if (param.equals("action:") && !hasAction) {
|
} else if (param.equals("action:") && !hasAction) {
|
||||||
|
|
||||||
params.add(param);
|
params.add(param);
|
||||||
|
|
||||||
} else if (param.equals("include:") && !hasInclude) {
|
} else if (param.equals("include:") && !hasInclude) {
|
||||||
|
|
||||||
params.add(param);
|
params.add(param);
|
||||||
|
|
||||||
} else if (param.equals("exclude:") && !hasExclude) {
|
} else if (param.equals("exclude:") && !hasExclude) {
|
||||||
|
|
||||||
params.add(param);
|
params.add(param);
|
||||||
|
|
||||||
} else if (param.equals("radius:") && !hasRadius) {
|
} else if (param.equals("radius:") && !hasRadius) {
|
||||||
|
|
||||||
params.add(param);
|
params.add(param);
|
||||||
|
|
||||||
} else if (param.equals("time:") && !hasTime) {
|
} else if (param.equals("time:") && !hasTime) {
|
||||||
|
|
||||||
params.add(param);
|
params.add(param);
|
||||||
|
|
||||||
} else if (param.equals("#container") && !hasContainer && !hasRadius && validContainer) {
|
} else if (param.equals("#container") && !hasContainer && !hasRadius && validContainer) {
|
||||||
|
|
||||||
params.add(param);
|
params.add(param);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstParam && pageLookup && (lastArgument.equals("l") || lastArgument.equals("lookup"))) {
|
if (firstParam && pageLookup && (lastArgument.equals("l") || lastArgument.equals("lookup"))) {
|
||||||
|
|
||||||
params.add("page:");
|
params.add("page:");
|
||||||
|
|
||||||
} else if (!firstParam && argument.startsWith("#")) {
|
} else if (!firstParam && argument.startsWith("#")) {
|
||||||
|
|
||||||
if (!hasCount) {
|
if (!hasCount) {
|
||||||
|
|
||||||
params.add("#count");
|
params.add("#count");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasPreview) {
|
if (!hasPreview) {
|
||||||
|
|
||||||
params.add("#preview");
|
params.add("#preview");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,50 +18,61 @@ import org.bukkit.entity.Player;
|
|||||||
public class TeleportCommand {
|
public class TeleportCommand {
|
||||||
|
|
||||||
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
protected static void runCommand(CommandSender player, boolean permission, String[] args) {
|
||||||
|
|
||||||
int resultc = args.length;
|
int resultc = args.length;
|
||||||
|
|
||||||
if (!permission) {
|
if (!permission) {
|
||||||
Chat.sendMessage(
|
|
||||||
player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
Chat.sendMessage(player,
|
||||||
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_PERMISSION));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(player instanceof Player)) {
|
if (!(player instanceof Player)) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.TELEPORT_PLAYERS));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.TELEPORT_PLAYERS));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.teleportThrottle.get(player.getName()) != null) {
|
if (ConfigHandler.teleportThrottle.get(player.getName()) != null) {
|
||||||
|
|
||||||
Object[] lookupThrottle = ConfigHandler.teleportThrottle.get(player.getName());
|
Object[] lookupThrottle = ConfigHandler.teleportThrottle.get(player.getName());
|
||||||
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 500) {
|
if ((boolean) lookupThrottle[0] || ((System.currentTimeMillis() - (long) lookupThrottle[1])) < 500) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_THROTTLED));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_THROTTLED));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultc < 3) {
|
if (resultc < 3) {
|
||||||
Chat.sendMessage(
|
|
||||||
player,
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.MISSING_PARAMETERS, "/co teleport <world> <x> <y> <z>"));
|
||||||
+ Phrase.build(Phrase.MISSING_PARAMETERS, "/co teleport <world> <x> <y> <z>"));
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String worldName = args[1];
|
String worldName = args[1];
|
||||||
int wid = Util.matchWorld(worldName);
|
int wid = Util.matchWorld(worldName);
|
||||||
if (wid == -1 && resultc >= 5) {
|
if (wid == -1 && resultc >= 5) {
|
||||||
|
|
||||||
Chat.sendMessage(player, new ChatMessage(Phrase.build(Phrase.WORLD_NOT_FOUND, worldName)).build());
|
Chat.sendMessage(player, new ChatMessage(Phrase.build(Phrase.WORLD_NOT_FOUND, worldName)).build());
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Location location = ((Player) player).getLocation().clone();
|
Location location = ((Player) player).getLocation().clone();
|
||||||
World world = location.getWorld();
|
World world = location.getWorld();
|
||||||
if (wid > -1) {
|
if (wid > -1) {
|
||||||
|
|
||||||
world = Bukkit.getServer().getWorld(Util.getWorldName(wid));
|
world = Bukkit.getServer().getWorld(Util.getWorldName(wid));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String x = null;
|
String x = null;
|
||||||
@@ -69,25 +80,40 @@ public class TeleportCommand {
|
|||||||
String z = null;
|
String z = null;
|
||||||
|
|
||||||
for (int i = 1; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
|
||||||
if (i == 1 && wid > -1) {
|
if (i == 1 && wid > -1) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x == null) {
|
if (x == null) {
|
||||||
|
|
||||||
x = args[i].replaceAll("[^0-9.\\-]", "");
|
x = args[i].replaceAll("[^0-9.\\-]", "");
|
||||||
|
|
||||||
} else if (z == null) {
|
} else if (z == null) {
|
||||||
|
|
||||||
z = args[i].replaceAll("[^0-9.\\-]", "");
|
z = args[i].replaceAll("[^0-9.\\-]", "");
|
||||||
|
|
||||||
} else if (y == null) {
|
} else if (y == null) {
|
||||||
|
|
||||||
y = z;
|
y = z;
|
||||||
z = args[i].replaceAll("[^0-9.\\-]", "");
|
z = args[i].replaceAll("[^0-9.\\-]", "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y == null) {
|
if (y == null) {
|
||||||
|
|
||||||
if (location.getBlockY() > 63) {
|
if (location.getBlockY() > 63) {
|
||||||
|
|
||||||
location.setY(63);
|
location.setY(63);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
y = Double.toString(location.getY());
|
y = Double.toString(location.getY());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String xValidate = x.replaceAll("[^.\\-]", "");
|
String xValidate = x.replaceAll("[^.\\-]", "");
|
||||||
@@ -96,12 +122,13 @@ public class TeleportCommand {
|
|||||||
|
|
||||||
if ((x.length() == 0 || x.length() >= 12 || x.equals(xValidate))
|
if ((x.length() == 0 || x.length() >= 12 || x.equals(xValidate))
|
||||||
|| (y.length() == 0 || y.length() >= 12 || y.equals(yValidate))
|
|| (y.length() == 0 || y.length() >= 12 || y.equals(yValidate))
|
||||||
|| (z.length() == 0 || z.length() >= 12 || z.equals(zValidate))) {
|
|| (z.length() == 0 || z.length() >= 12 || z.equals(zValidate)))
|
||||||
Chat.sendMessage(
|
{
|
||||||
player,
|
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(Phrase.MISSING_PARAMETERS, "/co teleport <world> <x> <y> <z>"));
|
+ Phrase.build(Phrase.MISSING_PARAMETERS, "/co teleport <world> <x> <y> <z>"));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
location.setWorld(world);
|
location.setWorld(world);
|
||||||
@@ -111,18 +138,21 @@ public class TeleportCommand {
|
|||||||
|
|
||||||
int chunkX = location.getBlockX() >> 4;
|
int chunkX = location.getBlockX() >> 4;
|
||||||
int chunkZ = location.getBlockZ() >> 4;
|
int chunkZ = location.getBlockZ() >> 4;
|
||||||
Scheduler.runTask(
|
Scheduler.runTask(CoreProtect.getInstance(), () -> {
|
||||||
CoreProtect.getInstance(),
|
|
||||||
() -> {
|
|
||||||
if (!location.getWorld().isChunkLoaded(chunkX, chunkZ)) {
|
|
||||||
location.getWorld().getChunkAt(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Teleport the player to a safe location
|
if (!location.getWorld().isChunkLoaded(chunkX, chunkZ)) {
|
||||||
Teleport.performSafeTeleport(((Player) player), location, true);
|
|
||||||
},
|
location.getWorld().getChunkAt(location);
|
||||||
location);
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Teleport the player to a safe location
|
||||||
|
Teleport.performSafeTeleport(((Player) player), location, true);
|
||||||
|
|
||||||
|
}, location);
|
||||||
|
|
||||||
|
ConfigHandler.teleportThrottle.put(player.getName(), new Object[] { false, System.currentTimeMillis() });
|
||||||
|
|
||||||
ConfigHandler.teleportThrottle.put(player.getName(), new Object[] {false, System.currentTimeMillis()});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,40 +11,64 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class UndoCommand {
|
public class UndoCommand {
|
||||||
|
|
||||||
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
|
protected static void runCommand(CommandSender user, Command command, boolean permission, String[] args) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
||||||
|
|
||||||
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
||||||
long startTime = (Long) list.get(0);
|
long startTime = (Long) list.get(0);
|
||||||
long endTime = (Long) list.get(1);
|
long endTime = (Long) list.get(1);
|
||||||
args = (String[]) list.get(2);
|
args = (String[]) list.get(2);
|
||||||
Location location = (Location) list.get(3);
|
Location location = (Location) list.get(3);
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
|
|
||||||
if (arg.equals("#preview")) {
|
if (arg.equals("#preview")) {
|
||||||
|
|
||||||
CancelCommand.runCommand(user, command, permission, args);
|
CancelCommand.runCommand(user, command, permission, args);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean valid = true;
|
boolean valid = true;
|
||||||
if (args[0].equals("rollback") || args[0].equals("rb") || args[0].equals("ro")) {
|
if (args[0].equals("rollback") || args[0].equals("rb") || args[0].equals("ro")) {
|
||||||
|
|
||||||
args[0] = "restore";
|
args[0] = "restore";
|
||||||
|
|
||||||
} else if (args[0].equals("restore") || args[0].equals("rs") || args[0].equals("re")) {
|
} else if (args[0].equals("restore") || args[0].equals("rs") || args[0].equals("re")) {
|
||||||
|
|
||||||
args[0] = "rollback";
|
args[0] = "rollback";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
valid = false;
|
valid = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|
||||||
ConfigHandler.lastRollback.remove(user.getName());
|
ConfigHandler.lastRollback.remove(user.getName());
|
||||||
RollbackRestoreCommand.runCommand(user, command, permission, args, location, startTime, endTime);
|
RollbackRestoreCommand.runCommand(user, command, permission, args, location, startTime, endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.NO_ROLLBACK, Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.NO_ROLLBACK, Selector.SECOND));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,16 +12,20 @@ import org.bukkit.entity.Player;
|
|||||||
public class WorldEditHandler {
|
public class WorldEditHandler {
|
||||||
|
|
||||||
protected static Integer[] runWorldEditCommand(CommandSender user) {
|
protected static Integer[] runWorldEditCommand(CommandSender user) {
|
||||||
|
|
||||||
Integer[] result = null;
|
Integer[] result = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
WorldEditPlugin worldEdit = WorldEditLogger.getWorldEdit(user.getServer());
|
WorldEditPlugin worldEdit = WorldEditLogger.getWorldEdit(user.getServer());
|
||||||
if (worldEdit != null && user instanceof Player) {
|
if (worldEdit != null && user instanceof Player) {
|
||||||
|
|
||||||
LocalSession session = worldEdit.getSession((Player) user);
|
LocalSession session = worldEdit.getSession((Player) user);
|
||||||
World world = session.getSelectionWorld();
|
World world = session.getSelectionWorld();
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
|
|
||||||
Region region = session.getSelection(world);
|
Region region = session.getSelection(world);
|
||||||
if (region != null
|
if (region != null && world.getName().equals(((Player) user).getWorld().getName())) {
|
||||||
&& world.getName().equals(((Player) user).getWorld().getName())) {
|
|
||||||
BlockVector3 block = region.getMinimumPoint();
|
BlockVector3 block = region.getMinimumPoint();
|
||||||
int x = block.x();
|
int x = block.x();
|
||||||
int y = block.y();
|
int y = block.y();
|
||||||
@@ -31,24 +35,39 @@ public class WorldEditHandler {
|
|||||||
int length = region.getLength();
|
int length = region.getLength();
|
||||||
int max = width;
|
int max = width;
|
||||||
if (height > max) {
|
if (height > max) {
|
||||||
|
|
||||||
max = height;
|
max = height;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > max) {
|
if (length > max) {
|
||||||
|
|
||||||
max = length;
|
max = length;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int xMin = x;
|
int xMin = x;
|
||||||
int xMax = x + (width - 1);
|
int xMax = x + (width - 1);
|
||||||
int yMin = y;
|
int yMin = y;
|
||||||
int yMax = y + (height - 1);
|
int yMax = y + (height - 1);
|
||||||
int zMin = z;
|
int zMin = z;
|
||||||
int zMax = z + (length - 1);
|
int zMax = z + (length - 1);
|
||||||
result = new Integer[] {max, xMin, xMax, yMin, yMax, zMin, zMax, 1};
|
result = new Integer[] { max, xMin, xMax, yMin, yMax, zMin, zMax, 1 };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -38,20 +38,27 @@ public class ConfigFile extends Config {
|
|||||||
private final HashMap<String, String> lang;
|
private final HashMap<String, String> lang;
|
||||||
|
|
||||||
public static void init(String fileName) throws IOException {
|
public static void init(String fileName) throws IOException {
|
||||||
|
|
||||||
for (Phrase phrase : Phrase.values()) {
|
for (Phrase phrase : Phrase.values()) {
|
||||||
|
|
||||||
DEFAULT_VALUES.put(phrase.name(), phrase.getPhrase());
|
DEFAULT_VALUES.put(phrase.name(), phrase.getPhrase());
|
||||||
USER_VALUES.put(phrase.name(), phrase.getUserPhrase());
|
USER_VALUES.put(phrase.name(), phrase.getUserPhrase());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isCache = fileName.startsWith(".");
|
boolean isCache = fileName.startsWith(".");
|
||||||
loadFiles(fileName, isCache);
|
loadFiles(fileName, isCache);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigFile() {
|
public ConfigFile() {
|
||||||
|
|
||||||
this.lang = new LinkedHashMap<>();
|
this.lang = new LinkedHashMap<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(final InputStream in, String fileName, boolean isCache) throws IOException {
|
public void load(final InputStream in, String fileName, boolean isCache) throws IOException {
|
||||||
|
|
||||||
// if we fail reading, we will not corrupt our current config.
|
// if we fail reading, we will not corrupt our current config.
|
||||||
final Map<String, String> newConfig = new LinkedHashMap<>(this.lang.size());
|
final Map<String, String> newConfig = new LinkedHashMap<>(this.lang.size());
|
||||||
ConfigFile.load(in, newConfig, true);
|
ConfigFile.load(in, newConfig, true);
|
||||||
@@ -60,35 +67,50 @@ public class ConfigFile extends Config {
|
|||||||
this.lang.putAll(newConfig);
|
this.lang.putAll(newConfig);
|
||||||
|
|
||||||
for (final Entry<String, String> entry : this.lang.entrySet()) {
|
for (final Entry<String, String> entry : this.lang.entrySet()) {
|
||||||
|
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
String value = entry.getValue();
|
String value = entry.getValue();
|
||||||
if (DEFAULT_VALUES.containsKey(key)
|
if (DEFAULT_VALUES.containsKey(key) && value.length() > 0
|
||||||
&& value.length() > 0
|
&& (!isCache || DEFAULT_VALUES.get(key).equals(USER_VALUES.get(key))))
|
||||||
&& (!isCache || DEFAULT_VALUES.get(key).equals(USER_VALUES.get(key)))) {
|
{
|
||||||
|
|
||||||
Phrase phrase = Phrase.valueOf(key);
|
Phrase phrase = Phrase.valueOf(key);
|
||||||
if (!isCache) {
|
if (!isCache) {
|
||||||
|
|
||||||
Language.setUserPhrase(phrase, value);
|
Language.setUserPhrase(phrase, value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Language.setTranslatedPhrase(phrase, value);
|
Language.setTranslatedPhrase(phrase, value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function will close in
|
// this function will close in
|
||||||
public static void load(final InputStream in, final Map<String, String> config, boolean forceCase)
|
public static void load(final InputStream in, final Map<String, String> config, boolean forceCase)
|
||||||
throws IOException {
|
throws IOException
|
||||||
|
{
|
||||||
|
|
||||||
try (final InputStream in0 = in) {
|
try (final InputStream in0 = in) {
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||||
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
|
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
|
||||||
|
|
||||||
if (line.startsWith("#")) {
|
if (line.startsWith("#")) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final int split = line.indexOf(':');
|
final int split = line.indexOf(':');
|
||||||
|
|
||||||
if (split == -1) {
|
if (split == -1) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String key = line.substring(0, split).trim();
|
String key = line.substring(0, split).trim();
|
||||||
@@ -96,37 +118,51 @@ public class ConfigFile extends Config {
|
|||||||
|
|
||||||
// Strip out single and double quotes from the start/end of the value
|
// Strip out single and double quotes from the start/end of the value
|
||||||
if (value.length() >= 2 && value.startsWith("'") && value.endsWith("'")) {
|
if (value.length() >= 2 && value.startsWith("'") && value.endsWith("'")) {
|
||||||
|
|
||||||
value = value.replaceAll("^'|'$", "");
|
value = value.replaceAll("^'|'$", "");
|
||||||
value = value.replace("''", "'");
|
value = value.replace("''", "'");
|
||||||
value = value.replace("\\'", "'");
|
value = value.replace("\\'", "'");
|
||||||
value = value.replace("\\\\", "\\");
|
value = value.replace("\\\\", "\\");
|
||||||
|
|
||||||
} else if (value.length() >= 2 && value.startsWith("\"") && value.endsWith("\"")) {
|
} else if (value.length() >= 2 && value.startsWith("\"") && value.endsWith("\"")) {
|
||||||
|
|
||||||
value = value.replaceAll("^\"|\"$", "");
|
value = value.replaceAll("^\"|\"$", "");
|
||||||
value = value.replace("\\\"", "\"");
|
value = value.replace("\\\"", "\"");
|
||||||
value = value.replace("\\\\", "\\");
|
value = value.replace("\\\\", "\\");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forceCase) {
|
if (forceCase) {
|
||||||
|
|
||||||
key = key.toUpperCase(Locale.ROOT);
|
key = key.toUpperCase(Locale.ROOT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.put(key, value);
|
config.put(key, value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, byte[]> loadFiles(String fileName, boolean isCache) throws IOException {
|
private static Map<String, byte[]> loadFiles(String fileName, boolean isCache) throws IOException {
|
||||||
|
|
||||||
final CoreProtect plugin = CoreProtect.getInstance();
|
final CoreProtect plugin = CoreProtect.getInstance();
|
||||||
final File configFolder = plugin.getDataFolder();
|
final File configFolder = plugin.getDataFolder();
|
||||||
if (!configFolder.exists()) {
|
if (!configFolder.exists()) {
|
||||||
|
|
||||||
configFolder.mkdirs();
|
configFolder.mkdirs();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, byte[]> map = new HashMap<>();
|
final Map<String, byte[]> map = new HashMap<>();
|
||||||
final File globalFile = new File(configFolder, fileName);
|
final File globalFile = new File(configFolder, fileName);
|
||||||
|
|
||||||
if (globalFile.exists()) {
|
if (globalFile.exists()) {
|
||||||
|
|
||||||
// we always add options to the global config
|
// we always add options to the global config
|
||||||
final byte[] data = Files.readAllBytes(globalFile.toPath());
|
final byte[] data = Files.readAllBytes(globalFile.toPath());
|
||||||
map.put("config", data);
|
map.put("config", data);
|
||||||
@@ -134,78 +170,112 @@ public class ConfigFile extends Config {
|
|||||||
final ConfigFile temp = new ConfigFile();
|
final ConfigFile temp = new ConfigFile();
|
||||||
temp.load(new ByteArrayInputStream(data), fileName, isCache);
|
temp.load(new ByteArrayInputStream(data), fileName, isCache);
|
||||||
temp.addMissingOptions(globalFile);
|
temp.addMissingOptions(globalFile);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
final ConfigFile temp = new ConfigFile();
|
final ConfigFile temp = new ConfigFile();
|
||||||
temp.addMissingOptions(globalFile);
|
temp.addMissingOptions(globalFile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMissingOptions(final File file) throws IOException {
|
public void addMissingOptions(final File file) throws IOException {
|
||||||
|
|
||||||
if (file.getName().startsWith(".")) {
|
if (file.getName().startsWith(".")) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean writeHeader = !file.exists() || file.length() == 0;
|
final boolean writeHeader = !file.exists() || file.length() == 0;
|
||||||
try (final FileOutputStream fout = new FileOutputStream(file, true)) {
|
try (final FileOutputStream fout = new FileOutputStream(file, true)) {
|
||||||
|
|
||||||
OutputStreamWriter out = new OutputStreamWriter(new BufferedOutputStream(fout), StandardCharsets.UTF_8);
|
OutputStreamWriter out = new OutputStreamWriter(new BufferedOutputStream(fout), StandardCharsets.UTF_8);
|
||||||
if (writeHeader) {
|
if (writeHeader) {
|
||||||
|
|
||||||
out.append(DEFAULT_FILE_HEADER);
|
out.append(DEFAULT_FILE_HEADER);
|
||||||
out.append(Config.LINE_SEPARATOR);
|
out.append(Config.LINE_SEPARATOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Entry<String, String> entry : DEFAULT_VALUES.entrySet()) {
|
for (final Entry<String, String> entry : DEFAULT_VALUES.entrySet()) {
|
||||||
|
|
||||||
final String key = entry.getKey();
|
final String key = entry.getKey();
|
||||||
final String defaultValue = entry.getValue().replaceAll("\"", "\\\\\"");
|
final String defaultValue = entry.getValue().replaceAll("\"", "\\\\\"");
|
||||||
|
|
||||||
final String configuredValue = this.lang.get(key);
|
final String configuredValue = this.lang.get(key);
|
||||||
if (configuredValue != null) {
|
if (configuredValue != null) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out.append(Config.LINE_SEPARATOR);
|
out.append(Config.LINE_SEPARATOR);
|
||||||
out.append(key);
|
out.append(key);
|
||||||
out.append(": ");
|
out.append(": ");
|
||||||
out.append("\"" + defaultValue + "\"");
|
out.append("\"" + defaultValue + "\"");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void modifyLine(String fileName, String oldLine, String newLine) {
|
public static void modifyLine(String fileName, String oldLine, String newLine) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Path path = Paths.get(ConfigHandler.path + fileName);
|
Path path = Paths.get(ConfigHandler.path + fileName);
|
||||||
List<String> lines = Files.readAllLines(path);
|
List<String> lines = Files.readAllLines(path);
|
||||||
|
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
|
|
||||||
if (lines.get(i).equalsIgnoreCase(oldLine)) {
|
if (lines.get(i).equalsIgnoreCase(oldLine)) {
|
||||||
|
|
||||||
if (newLine != null && newLine.length() > 0) {
|
if (newLine != null && newLine.length() > 0) {
|
||||||
|
|
||||||
lines.set(i, newLine);
|
lines.set(i, newLine);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
lines.remove(i);
|
lines.remove(i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines.size() > 0) {
|
if (lines.size() > 0) {
|
||||||
String lastLine = lines.get(
|
|
||||||
lines.size() - 1); // append the final line to prevent a line separator from being added
|
String lastLine = lines.get(lines.size() - 1); // append the final line to prevent a line separator from
|
||||||
|
// being added
|
||||||
Files.write(path, (lines.remove(lines.size() - 1).isEmpty() ? lines : lines), StandardCharsets.UTF_8);
|
Files.write(path, (lines.remove(lines.size() - 1).isEmpty() ? lines : lines), StandardCharsets.UTF_8);
|
||||||
Files.write(path, lastLine.getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND);
|
Files.write(path, lastLine.getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND);
|
||||||
lines.clear();
|
lines.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sortFile(String fileName) {
|
public static void sortFile(String fileName) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Path path = Paths.get(ConfigHandler.path + fileName);
|
Path path = Paths.get(ConfigHandler.path + fileName);
|
||||||
List<String> lines = Files.readAllLines(path);
|
List<String> lines = Files.readAllLines(path);
|
||||||
List<String> sort = lines.subList(2, lines.size());
|
List<String> sort = lines.subList(2, lines.size());
|
||||||
@@ -214,22 +284,33 @@ public class ConfigFile extends Config {
|
|||||||
lines.addAll(sort);
|
lines.addAll(sort);
|
||||||
|
|
||||||
if (lines.size() > 0) {
|
if (lines.size() > 0) {
|
||||||
String lastLine = lines.get(
|
|
||||||
lines.size() - 1); // append the final line to prevent a line separator from being added
|
String lastLine = lines.get(lines.size() - 1); // append the final line to prevent a line separator from
|
||||||
|
// being added
|
||||||
Files.write(path, (lines.remove(lines.size() - 1).isEmpty() ? lines : lines), StandardCharsets.UTF_8);
|
Files.write(path, (lines.remove(lines.size() - 1).isEmpty() ? lines : lines), StandardCharsets.UTF_8);
|
||||||
Files.write(path, lastLine.getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND);
|
Files.write(path, lastLine.getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND);
|
||||||
lines.clear();
|
lines.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resetCache(String cacheName, String fileName) throws IOException {
|
public static void resetCache(String cacheName, String fileName) throws IOException {
|
||||||
|
|
||||||
File file = new File(CoreProtect.getInstance().getDataFolder(), cacheName);
|
File file = new File(CoreProtect.getInstance().getDataFolder(), cacheName);
|
||||||
if (file.length() > 0) {
|
if (file.length() > 0) {
|
||||||
|
|
||||||
new FileOutputStream(file).close();
|
new FileOutputStream(file).close();
|
||||||
init(fileName);
|
init(fileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,7 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
import oshi.hardware.CentralProcessor;
|
import oshi.hardware.CentralProcessor;
|
||||||
|
|
||||||
public class ConfigHandler extends Queue {
|
public class ConfigHandler extends Queue {
|
||||||
|
|
||||||
public static int SERVER_VERSION = 0;
|
public static int SERVER_VERSION = 0;
|
||||||
public static final int EDITION_VERSION = 2;
|
public static final int EDITION_VERSION = 2;
|
||||||
public static final String EDITION_BRANCH = Util.getBranch();
|
public static final String EDITION_BRANCH = Util.getBranch();
|
||||||
@@ -74,7 +75,9 @@ public class ConfigHandler extends Queue {
|
|||||||
public static volatile int artId = 0;
|
public static volatile int artId = 0;
|
||||||
|
|
||||||
private static <K, V> Map<K, V> syncMap() {
|
private static <K, V> Map<K, V> syncMap() {
|
||||||
|
|
||||||
return Collections.synchronizedMap(new HashMap<>());
|
return Collections.synchronizedMap(new HashMap<>());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Integer> worlds = syncMap();
|
public static Map<String, Integer> worlds = syncMap();
|
||||||
@@ -131,50 +134,73 @@ public class ConfigHandler extends Queue {
|
|||||||
public static List<String> databaseTables = new ArrayList<>();
|
public static List<String> databaseTables = new ArrayList<>();
|
||||||
|
|
||||||
private static void checkPlayers(Connection connection) {
|
private static void checkPlayers(Connection connection) {
|
||||||
|
|
||||||
ConfigHandler.playerIdCache.clear();
|
ConfigHandler.playerIdCache.clear();
|
||||||
ConfigHandler.playerIdCacheReversed.clear();
|
ConfigHandler.playerIdCacheReversed.clear();
|
||||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
|
|
||||||
if (ConfigHandler.playerIdCache.get(player.getName().toLowerCase(Locale.ROOT)) == null) {
|
if (ConfigHandler.playerIdCache.get(player.getName().toLowerCase(Locale.ROOT)) == null) {
|
||||||
UserStatement.loadId(
|
|
||||||
connection, player.getName(), player.getUniqueId().toString());
|
UserStatement.loadId(connection, player.getName(), player.getUniqueId().toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadBlacklist() {
|
private static void loadBlacklist() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ConfigHandler.blacklist.clear();
|
ConfigHandler.blacklist.clear();
|
||||||
String blacklist = ConfigHandler.path + "blacklist.txt";
|
String blacklist = ConfigHandler.path + "blacklist.txt";
|
||||||
boolean exists = (new File(blacklist)).exists();
|
boolean exists = (new File(blacklist)).exists();
|
||||||
if (exists) {
|
if (exists) {
|
||||||
|
|
||||||
RandomAccessFile blfile = new RandomAccessFile(blacklist, "rw");
|
RandomAccessFile blfile = new RandomAccessFile(blacklist, "rw");
|
||||||
long blc = blfile.length();
|
long blc = blfile.length();
|
||||||
if (blc > 0) {
|
if (blc > 0) {
|
||||||
|
|
||||||
while (blfile.getFilePointer() < blfile.length()) {
|
while (blfile.getFilePointer() < blfile.length()) {
|
||||||
String blacklistUser =
|
|
||||||
blfile.readLine().replaceAll(" ", "").toLowerCase(Locale.ROOT);
|
String blacklistUser = blfile.readLine().replaceAll(" ", "").toLowerCase(Locale.ROOT);
|
||||||
if (blacklistUser.length() > 0) {
|
if (blacklistUser.length() > 0) {
|
||||||
|
|
||||||
ConfigHandler.blacklist.put(blacklistUser, true);
|
ConfigHandler.blacklist.put(blacklistUser, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blfile.close();
|
blfile.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadConfig() {
|
private static void loadConfig() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Config.init();
|
Config.init();
|
||||||
ConfigFile.init(ConfigFile.LANGUAGE); // load user phrases
|
ConfigFile.init(ConfigFile.LANGUAGE); // load user phrases
|
||||||
ConfigFile.init(ConfigFile.LANGUAGE_CACHE); // load translation cache
|
ConfigFile.init(ConfigFile.LANGUAGE_CACHE); // load translation cache
|
||||||
|
|
||||||
// Enforce "co_" table prefix if using SQLite.
|
// Enforce "co_" table prefix if using SQLite.
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
ConfigHandler.prefixConfig = Config.getGlobal().PREFIX;
|
ConfigHandler.prefixConfig = Config.getGlobal().PREFIX;
|
||||||
Config.getGlobal().PREFIX = "co_";
|
Config.getGlobal().PREFIX = "co_";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.host = Config.getGlobal().MYSQL_HOST;
|
ConfigHandler.host = Config.getGlobal().MYSQL_HOST;
|
||||||
@@ -186,49 +212,73 @@ public class ConfigHandler extends Queue {
|
|||||||
ConfigHandler.prefix = Config.getGlobal().PREFIX;
|
ConfigHandler.prefix = Config.getGlobal().PREFIX;
|
||||||
|
|
||||||
ConfigHandler.loadBlacklist(); // Load the blacklist file if it exists.
|
ConfigHandler.loadBlacklist(); // Load the blacklist file if it exists.
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadDatabase() {
|
public static void loadDatabase() {
|
||||||
|
|
||||||
// close old pool when we reload the database, e.g. in purge command
|
// close old pool when we reload the database, e.g. in purge command
|
||||||
Database.closeConnection();
|
Database.closeConnection();
|
||||||
|
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
File tempFile = File.createTempFile("CoreProtect_" + System.currentTimeMillis(), ".tmp");
|
File tempFile = File.createTempFile("CoreProtect_" + System.currentTimeMillis(), ".tmp");
|
||||||
tempFile.setExecutable(true);
|
tempFile.setExecutable(true);
|
||||||
|
|
||||||
boolean canExecute = false;
|
boolean canExecute = false;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
canExecute = tempFile.canExecute();
|
canExecute = tempFile.canExecute();
|
||||||
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
|
|
||||||
// execute access denied by security manager
|
// execute access denied by security manager
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canExecute) {
|
if (!canExecute) {
|
||||||
|
|
||||||
File tempFolder = new File("cache");
|
File tempFolder = new File("cache");
|
||||||
boolean exists = tempFolder.exists();
|
boolean exists = tempFolder.exists();
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
|
|
||||||
tempFolder.mkdir();
|
tempFolder.mkdir();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.setProperty("java.io.tmpdir", "cache");
|
System.setProperty("java.io.tmpdir", "cache");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tempFile.delete();
|
tempFile.delete();
|
||||||
|
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
HikariConfig config = new HikariConfig();
|
HikariConfig config = new HikariConfig();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||||
config.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
config.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
config.setDriverClassName("com.mysql.jdbc.Driver");
|
config.setDriverClassName("com.mysql.jdbc.Driver");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.setJdbcUrl(
|
config.setJdbcUrl(
|
||||||
@@ -240,7 +290,10 @@ public class ConfigHandler extends Queue {
|
|||||||
config.addDataSourceProperty("characterEncoding", "UTF-8");
|
config.addDataSourceProperty("characterEncoding", "UTF-8");
|
||||||
config.addDataSourceProperty("connectionTimeout", "10000");
|
config.addDataSourceProperty("connectionTimeout", "10000");
|
||||||
/* https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration */
|
/* https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration */
|
||||||
/* https://cdn.oreillystatic.com/en/assets/1/event/21/Connector_J%20Performance%20Gems%20Presentation.pdf */
|
/*
|
||||||
|
* https://cdn.oreillystatic.com/en/assets/1/event/21/Connector_J%20Performance%
|
||||||
|
* 20Gems%20Presentation.pdf
|
||||||
|
*/
|
||||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||||
@@ -254,13 +307,17 @@ public class ConfigHandler extends Queue {
|
|||||||
config.addDataSourceProperty("useSSL", Config.getGlobal().ENABLE_SSL);
|
config.addDataSourceProperty("useSSL", Config.getGlobal().ENABLE_SSL);
|
||||||
|
|
||||||
ConfigHandler.hikariDataSource = new HikariDataSource(config);
|
ConfigHandler.hikariDataSource = new HikariDataSource(config);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.createDatabaseTables(ConfigHandler.prefix, null, Config.getGlobal().MYSQL, false);
|
Database.createDatabaseTables(ConfigHandler.prefix, null, Config.getGlobal().MYSQL, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadTypes(Statement statement) {
|
public static void loadTypes(Statement statement) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String query = "SELECT id,material FROM " + ConfigHandler.prefix + "material_map";
|
String query = "SELECT id,material FROM " + ConfigHandler.prefix + "material_map";
|
||||||
ResultSet rs = statement.executeQuery(query);
|
ResultSet rs = statement.executeQuery(query);
|
||||||
ConfigHandler.materials.clear();
|
ConfigHandler.materials.clear();
|
||||||
@@ -268,14 +325,19 @@ public class ConfigHandler extends Queue {
|
|||||||
materialId = 0;
|
materialId = 0;
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
int id = rs.getInt("id");
|
int id = rs.getInt("id");
|
||||||
String material = rs.getString("material");
|
String material = rs.getString("material");
|
||||||
ConfigHandler.materials.put(material, id);
|
ConfigHandler.materials.put(material, id);
|
||||||
ConfigHandler.materialsReversed.put(id, material);
|
ConfigHandler.materialsReversed.put(id, material);
|
||||||
if (id > materialId) {
|
if (id > materialId) {
|
||||||
|
|
||||||
materialId = id;
|
materialId = id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
query = "SELECT id,data FROM " + ConfigHandler.prefix + "blockdata_map";
|
query = "SELECT id,data FROM " + ConfigHandler.prefix + "blockdata_map";
|
||||||
@@ -285,14 +347,19 @@ public class ConfigHandler extends Queue {
|
|||||||
blockdataId = 0;
|
blockdataId = 0;
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
int id = rs.getInt("id");
|
int id = rs.getInt("id");
|
||||||
String data = rs.getString("data");
|
String data = rs.getString("data");
|
||||||
ConfigHandler.blockdata.put(data, id);
|
ConfigHandler.blockdata.put(data, id);
|
||||||
ConfigHandler.blockdataReversed.put(id, data);
|
ConfigHandler.blockdataReversed.put(id, data);
|
||||||
if (id > blockdataId) {
|
if (id > blockdataId) {
|
||||||
|
|
||||||
blockdataId = id;
|
blockdataId = id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
query = "SELECT id,art FROM " + ConfigHandler.prefix + "art_map";
|
query = "SELECT id,art FROM " + ConfigHandler.prefix + "art_map";
|
||||||
@@ -302,14 +369,19 @@ public class ConfigHandler extends Queue {
|
|||||||
artId = 0;
|
artId = 0;
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
int id = rs.getInt("id");
|
int id = rs.getInt("id");
|
||||||
String art = rs.getString("art");
|
String art = rs.getString("art");
|
||||||
ConfigHandler.art.put(art, id);
|
ConfigHandler.art.put(art, id);
|
||||||
ConfigHandler.artReversed.put(id, art);
|
ConfigHandler.artReversed.put(id, art);
|
||||||
if (id > artId) {
|
if (id > artId) {
|
||||||
|
|
||||||
artId = id;
|
artId = id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
query = "SELECT id,entity FROM " + ConfigHandler.prefix + "entity_map";
|
query = "SELECT id,entity FROM " + ConfigHandler.prefix + "entity_map";
|
||||||
@@ -319,22 +391,33 @@ public class ConfigHandler extends Queue {
|
|||||||
entityId = 0;
|
entityId = 0;
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
int id = rs.getInt("id");
|
int id = rs.getInt("id");
|
||||||
String entity = rs.getString("entity");
|
String entity = rs.getString("entity");
|
||||||
ConfigHandler.entities.put(entity, id);
|
ConfigHandler.entities.put(entity, id);
|
||||||
ConfigHandler.entitiesReversed.put(id, entity);
|
ConfigHandler.entitiesReversed.put(id, entity);
|
||||||
if (id > entityId) {
|
if (id > entityId) {
|
||||||
|
|
||||||
entityId = id;
|
entityId = id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadWorlds(Statement statement) {
|
public static void loadWorlds(Statement statement) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String query = "SELECT id,world FROM " + ConfigHandler.prefix + "world";
|
String query = "SELECT id,world FROM " + ConfigHandler.prefix + "world";
|
||||||
ResultSet rs = statement.executeQuery(query);
|
ResultSet rs = statement.executeQuery(query);
|
||||||
ConfigHandler.worlds.clear();
|
ConfigHandler.worlds.clear();
|
||||||
@@ -342,40 +425,57 @@ public class ConfigHandler extends Queue {
|
|||||||
worldId = 0;
|
worldId = 0;
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
int id = rs.getInt("id");
|
int id = rs.getInt("id");
|
||||||
String world = rs.getString("world");
|
String world = rs.getString("world");
|
||||||
ConfigHandler.worlds.put(world, id);
|
ConfigHandler.worlds.put(world, id);
|
||||||
ConfigHandler.worldsReversed.put(id, world);
|
ConfigHandler.worldsReversed.put(id, world);
|
||||||
if (id > worldId) {
|
if (id > worldId) {
|
||||||
|
|
||||||
worldId = id;
|
worldId = id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
List<World> worlds = Bukkit.getServer().getWorlds();
|
List<World> worlds = Bukkit.getServer().getWorlds();
|
||||||
for (World world : worlds) {
|
for (World world : worlds) {
|
||||||
|
|
||||||
String worldname = world.getName();
|
String worldname = world.getName();
|
||||||
if (ConfigHandler.worlds.get(worldname) == null) {
|
if (ConfigHandler.worlds.get(worldname) == null) {
|
||||||
|
|
||||||
int id = worldId + 1;
|
int id = worldId + 1;
|
||||||
ConfigHandler.worlds.put(worldname, id);
|
ConfigHandler.worlds.put(worldname, id);
|
||||||
ConfigHandler.worldsReversed.put(id, worldname);
|
ConfigHandler.worldsReversed.put(id, worldname);
|
||||||
worldId = id;
|
worldId = id;
|
||||||
Queue.queueWorldInsert(id, worldname);
|
Queue.queueWorldInsert(id, worldname);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkDatabaseLock(Statement statement) {
|
private static boolean checkDatabaseLock(Statement statement) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (Config.getGlobal().DATABASE_LOCK) {
|
if (Config.getGlobal().DATABASE_LOCK) {
|
||||||
|
|
||||||
boolean locked = true;
|
boolean locked = true;
|
||||||
boolean lockMessage = false;
|
boolean lockMessage = false;
|
||||||
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||||
int waitTime = unixtimestamp + 15;
|
int waitTime = unixtimestamp + 15;
|
||||||
while (locked) {
|
while (locked) {
|
||||||
|
|
||||||
locked = false;
|
locked = false;
|
||||||
unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||||
int checkTime = unixtimestamp - 15;
|
int checkTime = unixtimestamp - 15;
|
||||||
@@ -383,13 +483,20 @@ public class ConfigHandler extends Queue {
|
|||||||
+ "database_lock WHERE rowid='1' AND status='1' AND time >= '" + checkTime + "' LIMIT 1";
|
+ "database_lock WHERE rowid='1' AND status='1' AND time >= '" + checkTime + "' LIMIT 1";
|
||||||
ResultSet rs = statement.executeQuery(query);
|
ResultSet rs = statement.executeQuery(query);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
if (unixtimestamp < waitTime) {
|
if (unixtimestamp < waitTime) {
|
||||||
|
|
||||||
if (!lockMessage) {
|
if (!lockMessage) {
|
||||||
|
|
||||||
Chat.sendConsoleMessage("[CoreProtect] " + Phrase.build(Phrase.DATABASE_LOCKED_1));
|
Chat.sendConsoleMessage("[CoreProtect] " + Phrase.build(Phrase.DATABASE_LOCKED_1));
|
||||||
lockMessage = true;
|
lockMessage = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Chat.sendConsoleMessage(
|
Chat.sendConsoleMessage(
|
||||||
Color.RED + "[CoreProtect] " + Phrase.build(Phrase.DATABASE_LOCKED_2));
|
Color.RED + "[CoreProtect] " + Phrase.build(Phrase.DATABASE_LOCKED_2));
|
||||||
Chat.sendConsoleMessage(
|
Chat.sendConsoleMessage(
|
||||||
@@ -397,22 +504,33 @@ public class ConfigHandler extends Queue {
|
|||||||
Chat.sendConsoleMessage(
|
Chat.sendConsoleMessage(
|
||||||
Color.GREY + "[CoreProtect] " + Phrase.build(Phrase.DATABASE_LOCKED_4));
|
Color.GREY + "[CoreProtect] " + Phrase.build(Phrase.DATABASE_LOCKED_4));
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
locked = true;
|
locked = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean performInitialization(boolean startup) {
|
public static boolean performInitialization(boolean startup) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
BukkitAdapter.loadAdapter();
|
BukkitAdapter.loadAdapter();
|
||||||
SpigotAdapter.loadAdapter();
|
SpigotAdapter.loadAdapter();
|
||||||
PaperAdapter.loadAdapter();
|
PaperAdapter.loadAdapter();
|
||||||
@@ -422,13 +540,19 @@ public class ConfigHandler extends Queue {
|
|||||||
ConfigHandler.loadDatabase(); // Initialize MySQL and create tables if necessary.
|
ConfigHandler.loadDatabase(); // Initialize MySQL and create tables if necessary.
|
||||||
|
|
||||||
if (startup) {
|
if (startup) {
|
||||||
|
|
||||||
ListenerHandler.registerNetworking(); // Register channels for networking API
|
ListenerHandler.registerNetworking(); // Register channels for networking API
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Connection connection = Database.getConnection(true, 0)) {
|
try (Connection connection = Database.getConnection(true, 0)) {
|
||||||
|
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
|
|
||||||
ConfigHandler.checkPlayers(connection);
|
ConfigHandler.checkPlayers(connection);
|
||||||
@@ -437,39 +561,58 @@ public class ConfigHandler extends Queue {
|
|||||||
|
|
||||||
// Initialize WorldEdit logging
|
// Initialize WorldEdit logging
|
||||||
if (Util.checkWorldEdit()) {
|
if (Util.checkWorldEdit()) {
|
||||||
|
|
||||||
PluginManager pluginManager = Bukkit.getServer().getPluginManager();
|
PluginManager pluginManager = Bukkit.getServer().getPluginManager();
|
||||||
Plugin worldEditPlugin = pluginManager.getPlugin("WorldEdit");
|
Plugin worldEditPlugin = pluginManager.getPlugin("WorldEdit");
|
||||||
if (worldEditPlugin != null && worldEditPlugin.isEnabled()) {
|
if (worldEditPlugin != null && worldEditPlugin.isEnabled()) {
|
||||||
|
|
||||||
Util.loadWorldEdit();
|
Util.loadWorldEdit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (ConfigHandler.worldeditEnabled) {
|
} else if (ConfigHandler.worldeditEnabled) {
|
||||||
|
|
||||||
Util.unloadWorldEdit();
|
Util.unloadWorldEdit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.serverRunning = true; // Set as running before patching
|
ConfigHandler.serverRunning = true; // Set as running before patching
|
||||||
boolean validVersion = Patch.versionCheck(statement); // Minor upgrades & version check
|
boolean validVersion = Patch.versionCheck(statement); // Minor upgrades & version check
|
||||||
boolean databaseLock = true;
|
boolean databaseLock = true;
|
||||||
if (startup) {
|
if (startup) {
|
||||||
|
|
||||||
// Check that database isn't already in use
|
// Check that database isn't already in use
|
||||||
databaseLock = ConfigHandler.checkDatabaseLock(statement);
|
databaseLock = ConfigHandler.checkDatabaseLock(statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
||||||
return validVersion && databaseLock;
|
return validVersion && databaseLock;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void performDisable() {
|
public static void performDisable() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Database.closeConnection();
|
Database.closeConnection();
|
||||||
ListenerHandler.unregisterNetworking(); // Unregister channels for networking API
|
ListenerHandler.unregisterNetworking(); // Unregister channels for networking API
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,70 +23,84 @@ public class Consumer extends Process implements Runnable, Thread.UncaughtExcept
|
|||||||
protected static volatile boolean pausedSuccess = false;
|
protected static volatile boolean pausedSuccess = false;
|
||||||
|
|
||||||
public static ConcurrentHashMap<Integer, ArrayList<Object[]>> consumer = new ConcurrentHashMap<>(4, 0.75f, 2);
|
public static ConcurrentHashMap<Integer, ArrayList<Object[]>> consumer = new ConcurrentHashMap<>(4, 0.75f, 2);
|
||||||
// public static ConcurrentHashMap<Integer, Integer[]> consumer_id = new ConcurrentHashMap<>();
|
// public static ConcurrentHashMap<Integer, Integer[]> consumer_id = new
|
||||||
|
// ConcurrentHashMap<>();
|
||||||
public static Map<Integer, Integer[]> consumer_id = Collections.synchronizedMap(new HashMap<>());
|
public static Map<Integer, Integer[]> consumer_id = Collections.synchronizedMap(new HashMap<>());
|
||||||
public static ConcurrentHashMap<Integer, Map<Integer, String[]>> consumerUsers =
|
public static ConcurrentHashMap<Integer, Map<Integer, String[]>> consumerUsers = new ConcurrentHashMap<>(4, 0.75f,
|
||||||
new ConcurrentHashMap<>(4, 0.75f, 2);
|
2);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static ConcurrentHashMap<Integer, Map<Integer, String>> consumerStrings =
|
public static ConcurrentHashMap<Integer, Map<Integer, String>> consumerStrings = new ConcurrentHashMap<>(4, 0.75f,
|
||||||
new ConcurrentHashMap<>(4, 0.75f, 2);
|
2);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static ConcurrentHashMap<Integer, Map<Integer, Object[]>> consumerSigns =
|
public static ConcurrentHashMap<Integer, Map<Integer, Object[]>> consumerSigns = new ConcurrentHashMap<>(4, 0.75f,
|
||||||
new ConcurrentHashMap<>(4, 0.75f, 2);
|
2);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static ConcurrentHashMap<Integer, Map<Integer, ItemStack[]>> consumerContainers =
|
public static ConcurrentHashMap<Integer, Map<Integer, ItemStack[]>> consumerContainers = new ConcurrentHashMap<>(4,
|
||||||
new ConcurrentHashMap<>(4, 0.75f, 2);
|
0.75f, 2);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static ConcurrentHashMap<Integer, Map<Integer, Object>> consumerInventories =
|
public static ConcurrentHashMap<Integer, Map<Integer, Object>> consumerInventories = new ConcurrentHashMap<>(4,
|
||||||
new ConcurrentHashMap<>(4, 0.75f, 2);
|
0.75f, 2);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static ConcurrentHashMap<Integer, Map<Integer, List<BlockState>>> consumerBlockList =
|
public static ConcurrentHashMap<Integer, Map<Integer, List<BlockState>>> consumerBlockList = new ConcurrentHashMap<>(
|
||||||
new ConcurrentHashMap<>(4, 0.75f, 2);
|
4, 0.75f, 2);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static ConcurrentHashMap<Integer, Map<Integer, List<Object[]>>> consumerObjectArrayList =
|
public static ConcurrentHashMap<Integer, Map<Integer, List<Object[]>>> consumerObjectArrayList = new ConcurrentHashMap<>(
|
||||||
new ConcurrentHashMap<>(4, 0.75f, 2);
|
4, 0.75f, 2);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static ConcurrentHashMap<Integer, Map<Integer, List<Object>>> consumerObjectList =
|
public static ConcurrentHashMap<Integer, Map<Integer, List<Object>>> consumerObjectList = new ConcurrentHashMap<>(4,
|
||||||
new ConcurrentHashMap<>(4, 0.75f, 2);
|
0.75f, 2);
|
||||||
|
|
||||||
public static ConcurrentHashMap<Integer, Map<Integer, Object>> consumerObjects =
|
public static ConcurrentHashMap<Integer, Map<Integer, Object>> consumerObjects = new ConcurrentHashMap<>(4, 0.75f,
|
||||||
new ConcurrentHashMap<>(4, 0.75f, 2);
|
2);
|
||||||
// ^merge maps into single object based map
|
// ^merge maps into single object based map
|
||||||
|
|
||||||
private static void errorDelay() {
|
private static void errorDelay() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Thread.sleep(30000); // 30 seconds
|
Thread.sleep(30000); // 30 seconds
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int newConsumerId(int consumer) {
|
protected static int newConsumerId(int consumer) {
|
||||||
|
|
||||||
int id = Consumer.consumer_id.get(consumer)[0];
|
int id = Consumer.consumer_id.get(consumer)[0];
|
||||||
Consumer.consumer_id.put(consumer, new Integer[] {id + 1, 1});
|
Consumer.consumer_id.put(consumer, new Integer[] { id + 1, 1 });
|
||||||
return id;
|
return id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getConsumerSize(int id) {
|
public static int getConsumerSize(int id) {
|
||||||
|
|
||||||
if (id == 0 || id == 1) {
|
if (id == 0 || id == 1) {
|
||||||
|
|
||||||
return Consumer.consumer.get(id).size();
|
return Consumer.consumer.get(id).size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
|
|
||||||
Consumer.consumer.put(0, new ArrayList<>());
|
Consumer.consumer.put(0, new ArrayList<>());
|
||||||
Consumer.consumer.put(1, new ArrayList<>());
|
Consumer.consumer.put(1, new ArrayList<>());
|
||||||
Consumer.consumer_id.put(0, new Integer[] {0, 0});
|
Consumer.consumer_id.put(0, new Integer[] { 0, 0 });
|
||||||
Consumer.consumer_id.put(1, new Integer[] {0, 0});
|
Consumer.consumer_id.put(1, new Integer[] { 0, 0 });
|
||||||
Consumer.consumerUsers.put(0, new HashMap<>());
|
Consumer.consumerUsers.put(0, new HashMap<>());
|
||||||
Consumer.consumerUsers.put(1, new HashMap<>());
|
Consumer.consumerUsers.put(1, new HashMap<>());
|
||||||
Consumer.consumerObjects.put(0, new HashMap<>());
|
Consumer.consumerObjects.put(0, new HashMap<>());
|
||||||
@@ -105,65 +119,99 @@ public class Consumer extends Process implements Runnable, Thread.UncaughtExcept
|
|||||||
Consumer.consumerObjectList.put(1, new HashMap<>());
|
Consumer.consumerObjectList.put(1, new HashMap<>());
|
||||||
Consumer.consumerContainers.put(0, new HashMap<>());
|
Consumer.consumerContainers.put(0, new HashMap<>());
|
||||||
Consumer.consumerContainers.put(1, new HashMap<>());
|
Consumer.consumerContainers.put(1, new HashMap<>());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRunning() {
|
public static boolean isRunning() {
|
||||||
|
|
||||||
return consumerThread != null && consumerThread.isAlive();
|
return consumerThread != null && consumerThread.isAlive();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void pauseConsumer(int process_id) {
|
private static void pauseConsumer(int process_id) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
while ((ConfigHandler.serverRunning || ConfigHandler.converterRunning || ConfigHandler.migrationRunning)
|
while ((ConfigHandler.serverRunning || ConfigHandler.converterRunning || ConfigHandler.migrationRunning)
|
||||||
&& (Consumer.isPaused
|
&& (Consumer.isPaused || ConfigHandler.pauseConsumer || ConfigHandler.purgeRunning
|
||||||
|| ConfigHandler.pauseConsumer
|
|| Consumer.consumer_id.get(process_id)[1] == 1))
|
||||||
|| ConfigHandler.purgeRunning
|
{
|
||||||
|| Consumer.consumer_id.get(process_id)[1] == 1)) {
|
|
||||||
pausedSuccess = true;
|
pausedSuccess = true;
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pausedSuccess = false;
|
pausedSuccess = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
boolean lastRun = false;
|
boolean lastRun = false;
|
||||||
|
|
||||||
while (ConfigHandler.serverRunning || ConfigHandler.converterRunning || !lastRun) {
|
while (ConfigHandler.serverRunning || ConfigHandler.converterRunning || !lastRun) {
|
||||||
|
|
||||||
if (!ConfigHandler.serverRunning && !ConfigHandler.converterRunning) {
|
if (!ConfigHandler.serverRunning && !ConfigHandler.converterRunning) {
|
||||||
|
|
||||||
lastRun = true;
|
lastRun = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
int process_id = 0;
|
int process_id = 0;
|
||||||
if (currentConsumer == 0) {
|
if (currentConsumer == 0) {
|
||||||
|
|
||||||
currentConsumer = 1;
|
currentConsumer = 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
process_id = 1;
|
process_id = 1;
|
||||||
currentConsumer = 0;
|
currentConsumer = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
pauseConsumer(process_id);
|
pauseConsumer(process_id);
|
||||||
Process.processConsumer(process_id, lastRun);
|
Process.processConsumer(process_id, lastRun);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
errorDelay();
|
errorDelay();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uncaughtException(Thread thread, Throwable e) {
|
public void uncaughtException(Thread thread, Throwable e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Bukkit.getPluginManager().disablePlugin(CoreProtect.getInstance());
|
Bukkit.getPluginManager().disablePlugin(CoreProtect.getInstance());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startConsumer() {
|
public static void startConsumer() {
|
||||||
|
|
||||||
if (!isRunning()) {
|
if (!isRunning()) {
|
||||||
|
|
||||||
consumerThread = new Thread(new Consumer());
|
consumerThread = new Thread(new Consumer());
|
||||||
consumerThread.setUncaughtExceptionHandler(new Consumer());
|
consumerThread.setUncaughtExceptionHandler(new Consumer());
|
||||||
consumerThread.start();
|
consumerThread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,155 +28,178 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class Queue {
|
public class Queue {
|
||||||
|
|
||||||
protected static synchronized int modifyForceContainer(String id, ItemStack[] container) {
|
protected static synchronized int modifyForceContainer(String id, ItemStack[] container) {
|
||||||
|
|
||||||
List<ItemStack[]> forceList = ConfigHandler.forceContainer.get(id);
|
List<ItemStack[]> forceList = ConfigHandler.forceContainer.get(id);
|
||||||
if (forceList == null) {
|
if (forceList == null) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container == null) {
|
if (container == null) {
|
||||||
|
|
||||||
forceList.remove(0);
|
forceList.remove(0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
forceList.add(container);
|
forceList.add(container);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return forceList.size();
|
return forceList.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static synchronized int getChestId(String id) {
|
protected static synchronized int getChestId(String id) {
|
||||||
|
|
||||||
int chestId = ConfigHandler.loggingChest.getOrDefault(id, -1) + 1;
|
int chestId = ConfigHandler.loggingChest.getOrDefault(id, -1) + 1;
|
||||||
ConfigHandler.loggingChest.put(id, chestId);
|
ConfigHandler.loggingChest.put(id, chestId);
|
||||||
return chestId;
|
return chestId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static synchronized int getItemId(String id) {
|
protected static synchronized int getItemId(String id) {
|
||||||
|
|
||||||
int chestId = ConfigHandler.loggingItem.getOrDefault(id, -1) + 1;
|
int chestId = ConfigHandler.loggingItem.getOrDefault(id, -1) + 1;
|
||||||
ConfigHandler.loggingItem.put(id, chestId);
|
ConfigHandler.loggingItem.put(id, chestId);
|
||||||
return chestId;
|
return chestId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static synchronized void addConsumer(int currentConsumer, Object[] data) {
|
private static synchronized void addConsumer(int currentConsumer, Object[] data) {
|
||||||
|
|
||||||
Consumer.consumer.get(currentConsumer).add(data);
|
Consumer.consumer.get(currentConsumer).add(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static synchronized void queueStandardData(
|
private static synchronized void queueStandardData(int consumerId, int currentConsumer, String[] user,
|
||||||
int consumerId, int currentConsumer, String[] user, Object object) {
|
Object object)
|
||||||
|
{
|
||||||
|
|
||||||
Consumer.consumerUsers.get(currentConsumer).put(consumerId, user);
|
Consumer.consumerUsers.get(currentConsumer).put(consumerId, user);
|
||||||
Consumer.consumerObjects.get(currentConsumer).put(consumerId, object);
|
Consumer.consumerObjects.get(currentConsumer).put(consumerId, object);
|
||||||
Consumer.consumer_id.put(
|
Consumer.consumer_id.put(currentConsumer, new Integer[] { Consumer.consumer_id.get(currentConsumer)[0], 0 });
|
||||||
currentConsumer, new Integer[] {Consumer.consumer_id.get(currentConsumer)[0], 0});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueAdvancedBreak(
|
protected static void queueAdvancedBreak(String user, BlockState block, Material type, String blockData, int data,
|
||||||
String user,
|
Material breakType, int blockNumber)
|
||||||
BlockState block,
|
{
|
||||||
Material type,
|
|
||||||
String blockData,
|
|
||||||
int data,
|
|
||||||
Material breakType,
|
|
||||||
int blockNumber) {
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(
|
addConsumer(currentConsumer,
|
||||||
currentConsumer,
|
new Object[]
|
||||||
new Object[] {consumerId, Process.BLOCK_BREAK, type, data, breakType, 0, blockNumber, blockData});
|
{ consumerId, Process.BLOCK_BREAK, type, data, breakType, 0, blockNumber, blockData });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, block);
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueArtInsert(int id, String name) {
|
protected static void queueArtInsert(int id, String name) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.ART_INSERT, null, 0, null, 0, id, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.ART_INSERT, null, 0, null, 0, id, null });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {null, null}, name);
|
queueStandardData(consumerId, currentConsumer, new String[] { null, null }, name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueBlockBreak(
|
protected static void queueBlockBreak(String user, BlockState block, Material type, String blockData,
|
||||||
String user, BlockState block, Material type, String blockData, int extraData) {
|
int extraData)
|
||||||
|
{
|
||||||
|
|
||||||
queueBlockBreak(user, block, type, blockData, null, extraData, 0);
|
queueBlockBreak(user, block, type, blockData, null, extraData, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueBlockBreakValidate(
|
protected static void queueBlockBreakValidate(final String user, final Block block, final BlockState blockState,
|
||||||
final String user,
|
final Material type, final String blockData, final int extraData, int ticks)
|
||||||
final Block block,
|
{
|
||||||
final BlockState blockState,
|
|
||||||
final Material type,
|
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||||
final String blockData,
|
|
||||||
final int extraData,
|
try {
|
||||||
int ticks) {
|
|
||||||
Scheduler.scheduleSyncDelayedTask(
|
if (!block.getType().equals(type)) {
|
||||||
CoreProtect.getInstance(),
|
|
||||||
() -> {
|
queueBlockBreak(user, blockState, type, blockData, null, extraData, 0);
|
||||||
try {
|
|
||||||
if (!block.getType().equals(type)) {
|
}
|
||||||
queueBlockBreak(user, blockState, type, blockData, null, extraData, 0);
|
|
||||||
}
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
|
||||||
},
|
}
|
||||||
block.getLocation(),
|
|
||||||
ticks);
|
}, block.getLocation(), ticks);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueBlockBreak(
|
protected static void queueBlockBreak(String user, BlockState block, Material type, String blockData,
|
||||||
String user,
|
Material breakType, int extraData, int blockNumber)
|
||||||
BlockState block,
|
{
|
||||||
Material type,
|
|
||||||
String blockData,
|
|
||||||
Material breakType,
|
|
||||||
int extraData,
|
|
||||||
int blockNumber) {
|
|
||||||
if (type == Material.SPAWNER && block instanceof CreatureSpawner) { // Mob spawner
|
if (type == Material.SPAWNER && block instanceof CreatureSpawner) { // Mob spawner
|
||||||
|
|
||||||
CreatureSpawner mobSpawner = (CreatureSpawner) block;
|
CreatureSpawner mobSpawner = (CreatureSpawner) block;
|
||||||
extraData = Util.getSpawnerType(mobSpawner.getSpawnedType());
|
extraData = Util.getSpawnerType(mobSpawner.getSpawnedType());
|
||||||
} else if (type == Material.IRON_DOOR
|
|
||||||
|| BlockGroup.DOORS.contains(type)
|
} else if (type == Material.IRON_DOOR || BlockGroup.DOORS.contains(type) || type.equals(Material.SUNFLOWER)
|
||||||
|| type.equals(Material.SUNFLOWER)
|
|| type.equals(Material.LILAC) || type.equals(Material.TALL_GRASS) || type.equals(Material.LARGE_FERN)
|
||||||
|| type.equals(Material.LILAC)
|
|| type.equals(Material.ROSE_BUSH) || type.equals(Material.PEONY))
|
||||||
|| type.equals(Material.TALL_GRASS)
|
{ // Double plant
|
||||||
|| type.equals(Material.LARGE_FERN)
|
|
||||||
|| type.equals(Material.ROSE_BUSH)
|
|
||||||
|| type.equals(Material.PEONY)) { // Double plant
|
|
||||||
if (block.getBlockData() instanceof Bisected) {
|
if (block.getBlockData() instanceof Bisected) {
|
||||||
|
|
||||||
if (((Bisected) block.getBlockData()).getHalf().equals(Half.TOP)) {
|
if (((Bisected) block.getBlockData()).getHalf().equals(Half.TOP)) {
|
||||||
|
|
||||||
if (blockNumber == 5) {
|
if (blockNumber == 5) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block.getY() > BukkitAdapter.ADAPTER.getMinHeight(block.getWorld())) {
|
if (block.getY() > BukkitAdapter.ADAPTER.getMinHeight(block.getWorld())) {
|
||||||
block = block.getWorld()
|
|
||||||
.getBlockAt(block.getX(), block.getY() - 1, block.getZ())
|
block = block.getWorld().getBlockAt(block.getX(), block.getY() - 1, block.getZ()).getState();
|
||||||
.getState();
|
|
||||||
if (type != block.getType()) {
|
if (type != block.getType()) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blockData = block.getBlockData().getAsString();
|
blockData = block.getBlockData().getAsString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type.name().endsWith("_BED") && block.getBlockData() instanceof Bed) {
|
} else if (type.name().endsWith("_BED") && block.getBlockData() instanceof Bed) {
|
||||||
|
|
||||||
if (((Bed) block.getBlockData()).getPart().equals(Part.HEAD)) {
|
if (((Bed) block.getBlockData()).getPart().equals(Part.HEAD)) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(
|
addConsumer(currentConsumer,
|
||||||
currentConsumer,
|
new Object[]
|
||||||
new Object[] {consumerId, Process.BLOCK_BREAK, type, extraData, breakType, 0, blockNumber, blockData});
|
{ consumerId, Process.BLOCK_BREAK, type, extraData, breakType, 0, blockNumber, blockData });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, block);
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueBlockPlace(
|
protected static void queueBlockPlace(String user, BlockState blockLocation, Material blockType,
|
||||||
String user,
|
BlockState blockReplaced, Material forceType, int forceD, int forceData, String blockData)
|
||||||
BlockState blockLocation,
|
{
|
||||||
Material blockType,
|
|
||||||
BlockState blockReplaced,
|
|
||||||
Material forceType,
|
|
||||||
int forceD,
|
|
||||||
int forceData,
|
|
||||||
String blockData) {
|
|
||||||
// If force_data equals "1", current block data will be used in consumer.
|
// If force_data equals "1", current block data will be used in consumer.
|
||||||
Material type = blockType;
|
Material type = blockType;
|
||||||
int data = 0;
|
int data = 0;
|
||||||
@@ -184,374 +207,400 @@ public class Queue {
|
|||||||
int replaceData = 0;
|
int replaceData = 0;
|
||||||
|
|
||||||
if (type == Material.SPAWNER && blockLocation instanceof CreatureSpawner) { // Mob spawner
|
if (type == Material.SPAWNER && blockLocation instanceof CreatureSpawner) { // Mob spawner
|
||||||
|
|
||||||
CreatureSpawner mobSpawner = (CreatureSpawner) blockLocation;
|
CreatureSpawner mobSpawner = (CreatureSpawner) blockLocation;
|
||||||
data = Util.getSpawnerType(mobSpawner.getSpawnedType());
|
data = Util.getSpawnerType(mobSpawner.getSpawnedType());
|
||||||
forceData = 1;
|
forceData = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockReplaced != null) {
|
if (blockReplaced != null) {
|
||||||
|
|
||||||
replaceType = blockReplaced.getType();
|
replaceType = blockReplaced.getType();
|
||||||
replaceData = 0;
|
replaceData = 0;
|
||||||
|
|
||||||
if ((replaceType == Material.IRON_DOOR
|
if ((replaceType == Material.IRON_DOOR || BlockGroup.DOORS.contains(replaceType)
|
||||||
|| BlockGroup.DOORS.contains(replaceType)
|
|| replaceType.equals(Material.SUNFLOWER) || replaceType.equals(Material.LILAC)
|
||||||
|| replaceType.equals(Material.SUNFLOWER)
|
|| replaceType.equals(Material.TALL_GRASS) || replaceType.equals(Material.LARGE_FERN)
|
||||||
|| replaceType.equals(Material.LILAC)
|
|| replaceType.equals(Material.ROSE_BUSH) || replaceType.equals(Material.PEONY))
|
||||||
|| replaceType.equals(Material.TALL_GRASS)
|
&& replaceData >= 8)
|
||||||
|| replaceType.equals(Material.LARGE_FERN)
|
{ // Double plant top half
|
||||||
|| replaceType.equals(Material.ROSE_BUSH)
|
|
||||||
|| replaceType.equals(Material.PEONY))
|
BlockState blockBelow = blockReplaced.getWorld()
|
||||||
&& replaceData >= 8) { // Double plant top half
|
.getBlockAt(blockReplaced.getX(), blockReplaced.getY() - 1, blockReplaced.getZ()).getState();
|
||||||
BlockState blockBelow = blockReplaced
|
|
||||||
.getWorld()
|
|
||||||
.getBlockAt(blockReplaced.getX(), blockReplaced.getY() - 1, blockReplaced.getZ())
|
|
||||||
.getState();
|
|
||||||
Material belowType = blockBelow.getType();
|
Material belowType = blockBelow.getType();
|
||||||
Queue.queueBlockBreak(
|
Queue.queueBlockBreak(user, blockBelow, belowType, blockBelow.getBlockData().getAsString(), 0);
|
||||||
user, blockBelow, belowType, blockBelow.getBlockData().getAsString(), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forceType != null) {
|
if (forceType != null) {
|
||||||
|
|
||||||
type = forceType;
|
type = forceType;
|
||||||
forceData = 1;
|
forceData = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forceD != -1) {
|
if (forceD != -1) {
|
||||||
|
|
||||||
data = forceD;
|
data = forceD;
|
||||||
forceData = 1;
|
forceData = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String replacedBlockData = null;
|
String replacedBlockData = null;
|
||||||
if (blockReplaced != null) {
|
if (blockReplaced != null) {
|
||||||
|
|
||||||
replacedBlockData = blockReplaced.getBlockData().getAsString();
|
replacedBlockData = blockReplaced.getBlockData().getAsString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {
|
addConsumer(currentConsumer,
|
||||||
consumerId,
|
new Object[]
|
||||||
Process.BLOCK_PLACE,
|
{ consumerId, Process.BLOCK_PLACE, type, data, replaceType, replaceData, forceData, blockData,
|
||||||
type,
|
replacedBlockData });
|
||||||
data,
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, blockLocation);
|
||||||
replaceType,
|
|
||||||
replaceData,
|
|
||||||
forceData,
|
|
||||||
blockData,
|
|
||||||
replacedBlockData
|
|
||||||
});
|
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, blockLocation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueBlockPlaceDelayed(
|
protected static void queueBlockPlaceDelayed(final String user, final Location placed, final Material type,
|
||||||
final String user,
|
final String blockData, final BlockState replaced, int ticks)
|
||||||
final Location placed,
|
{
|
||||||
final Material type,
|
|
||||||
final String blockData,
|
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||||
final BlockState replaced,
|
|
||||||
int ticks) {
|
try {
|
||||||
Scheduler.scheduleSyncDelayedTask(
|
|
||||||
CoreProtect.getInstance(),
|
queueBlockPlace(user, placed.getBlock().getState(), type, replaced, null, -1, 0, blockData);
|
||||||
() -> {
|
|
||||||
try {
|
} catch (Exception e) {
|
||||||
queueBlockPlace(user, placed.getBlock().getState(), type, replaced, null, -1, 0, blockData);
|
|
||||||
} catch (Exception e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
placed,
|
}, placed, ticks);
|
||||||
ticks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueBlockPlaceValidate(
|
protected static void queueBlockPlaceValidate(final String user, final BlockState blockLocation, final Block block,
|
||||||
final String user,
|
final BlockState blockReplaced, final Material forceT, final int forceD, final int forceData,
|
||||||
final BlockState blockLocation,
|
final String blockData, int ticks)
|
||||||
final Block block,
|
{
|
||||||
final BlockState blockReplaced,
|
|
||||||
final Material forceT,
|
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||||
final int forceD,
|
|
||||||
final int forceData,
|
try {
|
||||||
final String blockData,
|
|
||||||
int ticks) {
|
Material blockType = block.getType();
|
||||||
Scheduler.scheduleSyncDelayedTask(
|
if (blockType.equals(forceT)) {
|
||||||
CoreProtect.getInstance(),
|
|
||||||
() -> {
|
BlockState blockStateLocation = blockLocation;
|
||||||
try {
|
if (Config.getConfig(blockLocation.getWorld()).BLOCK_MOVEMENT) {
|
||||||
Material blockType = block.getType();
|
|
||||||
if (blockType.equals(forceT)) {
|
blockStateLocation = BlockUtil.gravityScan(blockLocation.getLocation(), blockType, user)
|
||||||
BlockState blockStateLocation = blockLocation;
|
.getState();
|
||||||
if (Config.getConfig(blockLocation.getWorld()).BLOCK_MOVEMENT) {
|
|
||||||
blockStateLocation = BlockUtil.gravityScan(blockLocation.getLocation(), blockType, user)
|
|
||||||
.getState();
|
|
||||||
}
|
|
||||||
|
|
||||||
queueBlockPlace(
|
|
||||||
user,
|
|
||||||
blockStateLocation,
|
|
||||||
blockType,
|
|
||||||
blockReplaced,
|
|
||||||
forceT,
|
|
||||||
forceD,
|
|
||||||
forceData,
|
|
||||||
blockData);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
blockLocation.getLocation(),
|
queueBlockPlace(user, blockStateLocation, blockType, blockReplaced, forceT, forceD, forceData,
|
||||||
ticks);
|
blockData);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, blockLocation.getLocation(), ticks);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueBlockGravityValidate(
|
protected static void queueBlockGravityValidate(final String user, final Location location, final Block block,
|
||||||
final String user, final Location location, final Block block, final Material blockType, int ticks) {
|
final Material blockType, int ticks)
|
||||||
Scheduler.scheduleSyncDelayedTask(
|
{
|
||||||
CoreProtect.getInstance(),
|
|
||||||
() -> {
|
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
|
||||||
try {
|
|
||||||
Block placementBlock = BlockUtil.gravityScan(location, blockType, user);
|
try {
|
||||||
if (!block.equals(placementBlock)) {
|
|
||||||
queueBlockPlace(user, placementBlock.getState(), blockType, null, blockType, -1, 0, null);
|
Block placementBlock = BlockUtil.gravityScan(location, blockType, user);
|
||||||
}
|
if (!block.equals(placementBlock)) {
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
queueBlockPlace(user, placementBlock.getState(), blockType, null, blockType, -1, 0, null);
|
||||||
}
|
|
||||||
},
|
}
|
||||||
location,
|
|
||||||
ticks);
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, location, ticks);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueContainerBreak(String user, Location location, Material type, ItemStack[] oldInventory) {
|
protected static void queueContainerBreak(String user, Location location, Material type, ItemStack[] oldInventory) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.CONTAINER_BREAK, type, 0, null, 0, 0, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.CONTAINER_BREAK, type, 0, null, 0, 0, null });
|
||||||
Consumer.consumerContainers.get(currentConsumer).put(consumerId, oldInventory);
|
Consumer.consumerContainers.get(currentConsumer).put(consumerId, oldInventory);
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, location);
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, location);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static synchronized void queueContainerTransaction(
|
protected static synchronized void queueContainerTransaction(String user, Location location, Material type,
|
||||||
String user, Location location, Material type, Object inventory, int chestId) {
|
Object inventory, int chestId)
|
||||||
|
{
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(
|
addConsumer(currentConsumer,
|
||||||
currentConsumer,
|
new Object[]
|
||||||
new Object[] {consumerId, Process.CONTAINER_TRANSACTION, type, 0, null, 0, chestId, null});
|
{ consumerId, Process.CONTAINER_TRANSACTION, type, 0, null, 0, chestId, null });
|
||||||
Consumer.consumerInventories.get(currentConsumer).put(consumerId, inventory);
|
Consumer.consumerInventories.get(currentConsumer).put(consumerId, inventory);
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, location);
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, location);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueItemTransaction(String user, Location location, int time, int offset, int itemId) {
|
protected static void queueItemTransaction(String user, Location location, int time, int offset, int itemId) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(
|
addConsumer(currentConsumer,
|
||||||
currentConsumer,
|
new Object[]
|
||||||
new Object[] {consumerId, Process.ITEM_TRANSACTION, null, offset, null, time, itemId, null});
|
{ consumerId, Process.ITEM_TRANSACTION, null, offset, null, time, itemId, null });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, location);
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, location);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueEntityInsert(int id, String name) {
|
protected static void queueEntityInsert(int id, String name) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.ENTITY_INSERT, null, 0, null, 0, id, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.ENTITY_INSERT, null, 0, null, 0, id, null });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {null, null}, name);
|
queueStandardData(consumerId, currentConsumer, new String[] { null, null }, name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueEntityKill(String user, Location location, List<Object> data, EntityType type) {
|
protected static void queueEntityKill(String user, Location location, List<Object> data, EntityType type) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.ENTITY_KILL, null, 0, null, 0, 0});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.ENTITY_KILL, null, 0, null, 0, 0 });
|
||||||
Consumer.consumerObjectList.get(currentConsumer).put(consumerId, data);
|
Consumer.consumerObjectList.get(currentConsumer).put(consumerId, data);
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, new Object[] {
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null },
|
||||||
location.getBlock().getState(), type, null
|
new Object[]
|
||||||
});
|
{ location.getBlock().getState(), type, null });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueEntitySpawn(String user, BlockState block, EntityType type, int data) {
|
protected static void queueEntitySpawn(String user, BlockState block, EntityType type, int data) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.ENTITY_SPAWN, null, 0, null, 0, data, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.ENTITY_SPAWN, null, 0, null, 0, data, null });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, new Object[] {block, type});
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, new Object[] { block, type });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueMaterialInsert(int id, String name) {
|
protected static void queueMaterialInsert(int id, String name) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.MATERIAL_INSERT, null, 0, null, 0, id, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.MATERIAL_INSERT, null, 0, null, 0, id, null });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {null, null}, name);
|
queueStandardData(consumerId, currentConsumer, new String[] { null, null }, name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueBlockDataInsert(int id, String data) {
|
protected static void queueBlockDataInsert(int id, String data) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.BLOCKDATA_INSERT, null, 0, null, 0, id, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.BLOCKDATA_INSERT, null, 0, null, 0, id, null });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {null, null}, data);
|
queueStandardData(consumerId, currentConsumer, new String[] { null, null }, data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueNaturalBlockBreak(
|
protected static void queueNaturalBlockBreak(String user, BlockState block, Block relative, Material type,
|
||||||
String user, BlockState block, Block relative, Material type, String blockData, int data) {
|
String blockData, int data)
|
||||||
|
{
|
||||||
|
|
||||||
List<BlockState> blockStates = new ArrayList<>();
|
List<BlockState> blockStates = new ArrayList<>();
|
||||||
if (relative != null) {
|
if (relative != null) {
|
||||||
|
|
||||||
blockStates.add(relative.getState());
|
blockStates.add(relative.getState());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(
|
addConsumer(currentConsumer,
|
||||||
currentConsumer,
|
new Object[]
|
||||||
new Object[] {consumerId, Process.NATURAL_BLOCK_BREAK, type, data, null, 0, 0, blockData});
|
{ consumerId, Process.NATURAL_BLOCK_BREAK, type, data, null, 0, 0, blockData });
|
||||||
Consumer.consumerBlockList.get(currentConsumer).put(consumerId, blockStates);
|
Consumer.consumerBlockList.get(currentConsumer).put(consumerId, blockStates);
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, block);
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queuePlayerChat(Player player, String message, long timestamp) {
|
protected static void queuePlayerChat(Player player, String message, long timestamp) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.PLAYER_CHAT, null, 0, null, 0, 0, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.PLAYER_CHAT, null, 0, null, 0, 0, null });
|
||||||
Consumer.consumerStrings.get(currentConsumer).put(consumerId, message);
|
Consumer.consumerStrings.get(currentConsumer).put(consumerId, message);
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {player.getName(), null}, new Object[] {
|
queueStandardData(consumerId, currentConsumer, new String[] { player.getName(), null },
|
||||||
timestamp, player.getLocation().clone()
|
new Object[]
|
||||||
});
|
{ timestamp, player.getLocation().clone() });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queuePlayerCommand(Player player, String message, long timestamp) {
|
protected static void queuePlayerCommand(Player player, String message, long timestamp) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.PLAYER_COMMAND, null, 0, null, 0, 0, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.PLAYER_COMMAND, null, 0, null, 0, 0, null });
|
||||||
Consumer.consumerStrings.get(currentConsumer).put(consumerId, message);
|
Consumer.consumerStrings.get(currentConsumer).put(consumerId, message);
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {player.getName(), null}, new Object[] {
|
queueStandardData(consumerId, currentConsumer, new String[] { player.getName(), null },
|
||||||
timestamp, player.getLocation().clone()
|
new Object[]
|
||||||
});
|
{ timestamp, player.getLocation().clone() });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queuePlayerInteraction(String user, BlockState block, Material type) {
|
protected static void queuePlayerInteraction(String user, BlockState block, Material type) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.PLAYER_INTERACTION, type, 0, null, 0, 0, null});
|
addConsumer(currentConsumer,
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, block);
|
new Object[]
|
||||||
|
{ consumerId, Process.PLAYER_INTERACTION, type, 0, null, 0, 0, null });
|
||||||
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queuePlayerKill(String user, Location location, String player) {
|
protected static void queuePlayerKill(String user, Location location, String player) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.PLAYER_KILL, null, 0, null, 0, 0, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.PLAYER_KILL, null, 0, null, 0, 0, null });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, new Object[] {
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null },
|
||||||
location.getBlock().getState(), player
|
new Object[]
|
||||||
});
|
{ location.getBlock().getState(), player });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queuePlayerLogin(Player player, int time, int configSessions, int configUsernames) {
|
protected static void queuePlayerLogin(Player player, int time, int configSessions, int configUsernames) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
String uuid = player.getUniqueId().toString();
|
String uuid = player.getUniqueId().toString();
|
||||||
addConsumer(currentConsumer, new Object[] {
|
addConsumer(currentConsumer,
|
||||||
consumerId, Process.PLAYER_LOGIN, null, configSessions, null, configUsernames, time, null
|
new Object[]
|
||||||
});
|
{ consumerId, Process.PLAYER_LOGIN, null, configSessions, null, configUsernames, time, null });
|
||||||
Consumer.consumerStrings.get(currentConsumer).put(consumerId, uuid);
|
Consumer.consumerStrings.get(currentConsumer).put(consumerId, uuid);
|
||||||
queueStandardData(
|
queueStandardData(consumerId, currentConsumer, new String[] { player.getName(), uuid },
|
||||||
consumerId,
|
|
||||||
currentConsumer,
|
|
||||||
new String[] {player.getName(), uuid},
|
|
||||||
player.getLocation().clone());
|
player.getLocation().clone());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queuePlayerQuit(Player player, int time) {
|
protected static void queuePlayerQuit(Player player, int time) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.PLAYER_LOGOUT, null, 0, null, 0, time, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.PLAYER_LOGOUT, null, 0, null, 0, time, null });
|
||||||
queueStandardData(
|
queueStandardData(consumerId, currentConsumer, new String[] { player.getName(), null },
|
||||||
consumerId,
|
|
||||||
currentConsumer,
|
|
||||||
new String[] {player.getName(), null},
|
|
||||||
player.getLocation().clone());
|
player.getLocation().clone());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueRollbackUpdate(
|
protected static void queueRollbackUpdate(String user, Location location, List<Object[]> list, int table,
|
||||||
String user, Location location, List<Object[]> list, int table, int action) {
|
int action)
|
||||||
|
{
|
||||||
|
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
|
|
||||||
location = new Location(Bukkit.getServer().getWorlds().get(0), 0, 0, 0);
|
location = new Location(Bukkit.getServer().getWorlds().get(0), 0, 0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, table, null, 0, null, 0, action, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, table, null, 0, null, 0, action, null });
|
||||||
Consumer.consumerObjectArrayList.get(currentConsumer).put(consumerId, list);
|
Consumer.consumerObjectArrayList.get(currentConsumer).put(consumerId, list);
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, location);
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, location);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueSignText(
|
protected static void queueSignText(String user, Location location, int action, int color, int colorSecondary,
|
||||||
String user,
|
boolean frontGlowing, boolean backGlowing, boolean isWaxed, boolean isFront, String line1, String line2,
|
||||||
Location location,
|
String line3, String line4, String line5, String line6, String line7, String line8, int offset)
|
||||||
int action,
|
{
|
||||||
int color,
|
|
||||||
int colorSecondary,
|
|
||||||
boolean frontGlowing,
|
|
||||||
boolean backGlowing,
|
|
||||||
boolean isWaxed,
|
|
||||||
boolean isFront,
|
|
||||||
String line1,
|
|
||||||
String line2,
|
|
||||||
String line3,
|
|
||||||
String line4,
|
|
||||||
String line5,
|
|
||||||
String line6,
|
|
||||||
String line7,
|
|
||||||
String line8,
|
|
||||||
int offset) {
|
|
||||||
/*
|
/*
|
||||||
if (line1.length() == 0 && line2.length() == 0 && line3.length() == 0 && line4.length() == 0) {
|
* if (line1.length() == 0 && line2.length() == 0 && line3.length() == 0 &&
|
||||||
return;
|
* line4.length() == 0) { return; }
|
||||||
}
|
*/
|
||||||
*/
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(
|
addConsumer(currentConsumer,
|
||||||
currentConsumer, new Object[] {consumerId, Process.SIGN_TEXT, null, color, null, action, offset, null});
|
new Object[]
|
||||||
Consumer.consumerSigns.get(currentConsumer).put(consumerId, new Object[] {
|
{ consumerId, Process.SIGN_TEXT, null, color, null, action, offset, null });
|
||||||
colorSecondary,
|
Consumer.consumerSigns.get(currentConsumer).put(consumerId,
|
||||||
Util.getSignData(frontGlowing, backGlowing),
|
new Object[]
|
||||||
isWaxed,
|
{ colorSecondary, Util.getSignData(frontGlowing, backGlowing), isWaxed, isFront, line1, line2, line3,
|
||||||
isFront,
|
line4, line5, line6, line7, line8 });
|
||||||
line1,
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, location);
|
||||||
line2,
|
|
||||||
line3,
|
|
||||||
line4,
|
|
||||||
line5,
|
|
||||||
line6,
|
|
||||||
line7,
|
|
||||||
line8
|
|
||||||
});
|
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueSignUpdate(String user, BlockState block, int action, int time) {
|
protected static void queueSignUpdate(String user, BlockState block, int action, int time) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.SIGN_UPDATE, null, action, null, 0, time, null});
|
addConsumer(currentConsumer,
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, block);
|
new Object[]
|
||||||
|
{ consumerId, Process.SIGN_UPDATE, null, action, null, 0, time, null });
|
||||||
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueSkullUpdate(String user, BlockState block, int rowId) {
|
protected static void queueSkullUpdate(String user, BlockState block, int rowId) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.SKULL_UPDATE, null, 0, null, 0, rowId, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.SKULL_UPDATE, null, 0, null, 0, rowId, null });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, block);
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueStructureGrow(
|
protected static void queueStructureGrow(String user, BlockState block, List<BlockState> blockList,
|
||||||
String user, BlockState block, List<BlockState> blockList, int replacedListSize) {
|
int replacedListSize)
|
||||||
|
{
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(
|
addConsumer(currentConsumer,
|
||||||
currentConsumer,
|
new Object[]
|
||||||
new Object[] {consumerId, Process.STRUCTURE_GROWTH, null, 0, null, 0, replacedListSize, null});
|
{ consumerId, Process.STRUCTURE_GROWTH, null, 0, null, 0, replacedListSize, null });
|
||||||
Consumer.consumerBlockList.get(currentConsumer).put(consumerId, blockList);
|
Consumer.consumerBlockList.get(currentConsumer).put(consumerId, blockList);
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {user, null}, block);
|
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void queueWorldInsert(int id, String world) {
|
protected static void queueWorldInsert(int id, String world) {
|
||||||
|
|
||||||
int currentConsumer = Consumer.currentConsumer;
|
int currentConsumer = Consumer.currentConsumer;
|
||||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||||
addConsumer(currentConsumer, new Object[] {consumerId, Process.WORLD_INSERT, null, 0, null, 0, id, null});
|
addConsumer(currentConsumer, new Object[] { consumerId, Process.WORLD_INSERT, null, 0, null, 0, id, null });
|
||||||
queueStandardData(consumerId, currentConsumer, new String[] {null, null}, world);
|
queueStandardData(consumerId, currentConsumer, new String[] { null, null }, world);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,26 +10,39 @@ import net.coreprotect.utility.Chat;
|
|||||||
|
|
||||||
class ArtInsertProcess {
|
class ArtInsertProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, Statement statement, int batchCount, Object name,
|
||||||
PreparedStatement preparedStmt, Statement statement, int batchCount, Object name, int materialId) {
|
int materialId)
|
||||||
|
{
|
||||||
|
|
||||||
if (name instanceof String) {
|
if (name instanceof String) {
|
||||||
String query =
|
|
||||||
"SELECT id FROM " + ConfigHandler.prefix + "art_map WHERE id = '" + materialId + "' LIMIT 0, 1";
|
String query = "SELECT id FROM " + ConfigHandler.prefix + "art_map WHERE id = '" + materialId
|
||||||
|
+ "' LIMIT 0, 1";
|
||||||
boolean hasMaterial = MaterialStatement.hasMaterial(statement, query);
|
boolean hasMaterial = MaterialStatement.hasMaterial(statement, query);
|
||||||
if (!hasMaterial) {
|
if (!hasMaterial) {
|
||||||
|
|
||||||
MaterialStatement.insert(preparedStmt, batchCount, materialId, (String) name);
|
MaterialStatement.insert(preparedStmt, batchCount, materialId, (String) name);
|
||||||
|
|
||||||
// validate ID maps to ensure mapping wasn't reloaded from database prior to this insertion completing
|
// validate ID maps to ensure mapping wasn't reloaded from database prior to
|
||||||
|
// this insertion completing
|
||||||
ConfigHandler.art.put((String) name, materialId);
|
ConfigHandler.art.put((String) name, materialId);
|
||||||
ConfigHandler.artReversed.put(materialId, (String) name);
|
ConfigHandler.artReversed.put(materialId, (String) name);
|
||||||
if (materialId > ConfigHandler.artId) {
|
if (materialId > ConfigHandler.artId) {
|
||||||
|
|
||||||
ConfigHandler.artId = materialId;
|
ConfigHandler.artId = materialId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.CACHE_ERROR, "art"));
|
Chat.console(Phrase.build(Phrase.CACHE_ERROR, "art"));
|
||||||
Chat.console(Phrase.build(Phrase.CACHE_RELOAD, Selector.FIRST));
|
Chat.console(Phrase.build(Phrase.CACHE_RELOAD, Selector.FIRST));
|
||||||
ConfigHandler.loadTypes(statement);
|
ConfigHandler.loadTypes(statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,36 +11,28 @@ import org.bukkit.block.Skull;
|
|||||||
|
|
||||||
class BlockBreakProcess {
|
class BlockBreakProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, PreparedStatement preparedStmtSkulls, int batchCount,
|
||||||
PreparedStatement preparedStmt,
|
int processId, int id, Material blockType, int blockDataId, Material replaceType, int forceData,
|
||||||
PreparedStatement preparedStmtSkulls,
|
String user, Object object, String blockData)
|
||||||
int batchCount,
|
{
|
||||||
int processId,
|
|
||||||
int id,
|
|
||||||
Material blockType,
|
|
||||||
int blockDataId,
|
|
||||||
Material replaceType,
|
|
||||||
int forceData,
|
|
||||||
String user,
|
|
||||||
Object object,
|
|
||||||
String blockData) {
|
|
||||||
if (object instanceof BlockState) {
|
if (object instanceof BlockState) {
|
||||||
|
|
||||||
BlockState block = (BlockState) object;
|
BlockState block = (BlockState) object;
|
||||||
List<Object> meta = Util.processMeta(block);
|
List<Object> meta = Util.processMeta(block);
|
||||||
if (block instanceof Skull) {
|
if (block instanceof Skull) {
|
||||||
|
|
||||||
SkullBreakLogger.log(preparedStmt, preparedStmtSkulls, batchCount, user, block);
|
SkullBreakLogger.log(preparedStmt, preparedStmtSkulls, batchCount, user, block);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
BlockBreakLogger.log(
|
|
||||||
preparedStmt,
|
BlockBreakLogger.log(preparedStmt, batchCount, user, block.getLocation(), Util.getBlockId(blockType),
|
||||||
batchCount,
|
blockDataId, meta, block.getBlockData().getAsString(), blockData);
|
||||||
user,
|
|
||||||
block.getLocation(),
|
|
||||||
Util.getBlockId(blockType),
|
|
||||||
blockDataId,
|
|
||||||
meta,
|
|
||||||
block.getBlockData().getAsString(),
|
|
||||||
blockData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,26 +10,39 @@ import net.coreprotect.utility.Chat;
|
|||||||
|
|
||||||
class BlockDataInsertProcess {
|
class BlockDataInsertProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, Statement statement, int batchCount, Object name,
|
||||||
PreparedStatement preparedStmt, Statement statement, int batchCount, Object name, int materialId) {
|
int materialId)
|
||||||
|
{
|
||||||
|
|
||||||
if (name instanceof String) {
|
if (name instanceof String) {
|
||||||
|
|
||||||
String query = "SELECT id FROM " + ConfigHandler.prefix + "blockdata_map WHERE id = '" + materialId
|
String query = "SELECT id FROM " + ConfigHandler.prefix + "blockdata_map WHERE id = '" + materialId
|
||||||
+ "' LIMIT 0, 1";
|
+ "' LIMIT 0, 1";
|
||||||
boolean hasMaterial = MaterialStatement.hasMaterial(statement, query);
|
boolean hasMaterial = MaterialStatement.hasMaterial(statement, query);
|
||||||
if (!hasMaterial) {
|
if (!hasMaterial) {
|
||||||
|
|
||||||
MaterialStatement.insert(preparedStmt, batchCount, materialId, (String) name);
|
MaterialStatement.insert(preparedStmt, batchCount, materialId, (String) name);
|
||||||
|
|
||||||
// validate ID maps to ensure mapping wasn't reloaded from database prior to this insertion completing
|
// validate ID maps to ensure mapping wasn't reloaded from database prior to
|
||||||
|
// this insertion completing
|
||||||
ConfigHandler.blockdata.put((String) name, materialId);
|
ConfigHandler.blockdata.put((String) name, materialId);
|
||||||
ConfigHandler.blockdataReversed.put(materialId, (String) name);
|
ConfigHandler.blockdataReversed.put(materialId, (String) name);
|
||||||
if (materialId > ConfigHandler.blockdataId) {
|
if (materialId > ConfigHandler.blockdataId) {
|
||||||
|
|
||||||
ConfigHandler.blockdataId = materialId;
|
ConfigHandler.blockdataId = materialId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.CACHE_ERROR, "blockdata"));
|
Chat.console(Phrase.build(Phrase.CACHE_ERROR, "blockdata"));
|
||||||
Chat.console(Phrase.build(Phrase.CACHE_RELOAD, Selector.FIRST));
|
Chat.console(Phrase.build(Phrase.CACHE_RELOAD, Selector.FIRST));
|
||||||
ConfigHandler.loadTypes(statement);
|
ConfigHandler.loadTypes(statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,71 +10,41 @@ import org.bukkit.block.BlockState;
|
|||||||
|
|
||||||
class BlockPlaceProcess {
|
class BlockPlaceProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, PreparedStatement preparedStmtSkulls, int batchCount,
|
||||||
PreparedStatement preparedStmt,
|
Material blockType, int blockData, Material replaceType, int replaceData, int forceData, String user,
|
||||||
PreparedStatement preparedStmtSkulls,
|
Object object, String newBlockData, String replacedBlockData)
|
||||||
int batchCount,
|
{
|
||||||
Material blockType,
|
|
||||||
int blockData,
|
|
||||||
Material replaceType,
|
|
||||||
int replaceData,
|
|
||||||
int forceData,
|
|
||||||
String user,
|
|
||||||
Object object,
|
|
||||||
String newBlockData,
|
|
||||||
String replacedBlockData) {
|
|
||||||
if (object instanceof BlockState) {
|
if (object instanceof BlockState) {
|
||||||
|
|
||||||
BlockState block = (BlockState) object;
|
BlockState block = (BlockState) object;
|
||||||
List<Object> meta = Util.processMeta(block);
|
List<Object> meta = Util.processMeta(block);
|
||||||
if (blockType.equals(Material.SKELETON_SKULL)
|
if (blockType.equals(Material.SKELETON_SKULL) || blockType.equals(Material.SKELETON_WALL_SKULL)
|
||||||
|| blockType.equals(Material.SKELETON_WALL_SKULL)
|
|
||||||
|| blockType.equals(Material.WITHER_SKELETON_SKULL)
|
|| blockType.equals(Material.WITHER_SKELETON_SKULL)
|
||||||
|| blockType.equals(Material.WITHER_SKELETON_WALL_SKULL)
|
|| blockType.equals(Material.WITHER_SKELETON_WALL_SKULL) || blockType.equals(Material.ZOMBIE_HEAD)
|
||||||
|| blockType.equals(Material.ZOMBIE_HEAD)
|
|| blockType.equals(Material.ZOMBIE_WALL_HEAD) || blockType.equals(Material.PLAYER_HEAD)
|
||||||
|| blockType.equals(Material.ZOMBIE_WALL_HEAD)
|
|| blockType.equals(Material.PLAYER_WALL_HEAD) || blockType.equals(Material.CREEPER_HEAD)
|
||||||
|| blockType.equals(Material.PLAYER_HEAD)
|
|| blockType.equals(Material.CREEPER_WALL_HEAD) || blockType.equals(Material.DRAGON_HEAD)
|
||||||
|| blockType.equals(Material.PLAYER_WALL_HEAD)
|
|| blockType.equals(Material.DRAGON_WALL_HEAD))
|
||||||
|| blockType.equals(Material.CREEPER_HEAD)
|
{
|
||||||
|| blockType.equals(Material.CREEPER_WALL_HEAD)
|
|
||||||
|| blockType.equals(Material.DRAGON_HEAD)
|
SkullPlaceLogger.log(preparedStmt, preparedStmtSkulls, batchCount, user, block,
|
||||||
|| blockType.equals(Material.DRAGON_WALL_HEAD)) {
|
Util.getBlockId(replaceType), replaceData);
|
||||||
SkullPlaceLogger.log(
|
|
||||||
preparedStmt,
|
|
||||||
preparedStmtSkulls,
|
|
||||||
batchCount,
|
|
||||||
user,
|
|
||||||
block,
|
|
||||||
Util.getBlockId(replaceType),
|
|
||||||
replaceData);
|
|
||||||
} else if (forceData == 1) {
|
} else if (forceData == 1) {
|
||||||
BlockPlaceLogger.log(
|
|
||||||
preparedStmt,
|
BlockPlaceLogger.log(preparedStmt, batchCount, user, block, Util.getBlockId(replaceType), replaceData,
|
||||||
batchCount,
|
blockType, blockData, true, meta, newBlockData, replacedBlockData);
|
||||||
user,
|
|
||||||
block,
|
|
||||||
Util.getBlockId(replaceType),
|
|
||||||
replaceData,
|
|
||||||
blockType,
|
|
||||||
blockData,
|
|
||||||
true,
|
|
||||||
meta,
|
|
||||||
newBlockData,
|
|
||||||
replacedBlockData);
|
|
||||||
} else {
|
} else {
|
||||||
BlockPlaceLogger.log(
|
|
||||||
preparedStmt,
|
BlockPlaceLogger.log(preparedStmt, batchCount, user, block, Util.getBlockId(replaceType), replaceData,
|
||||||
batchCount,
|
blockType, blockData, false, meta, newBlockData, replacedBlockData);
|
||||||
user,
|
|
||||||
block,
|
|
||||||
Util.getBlockId(replaceType),
|
|
||||||
replaceData,
|
|
||||||
blockType,
|
|
||||||
blockData,
|
|
||||||
false,
|
|
||||||
meta,
|
|
||||||
newBlockData,
|
|
||||||
replacedBlockData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,22 +10,24 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
class ContainerBreakProcess {
|
class ContainerBreakProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Material type,
|
||||||
PreparedStatement preparedStmt,
|
String user, Object object)
|
||||||
int batchCount,
|
{
|
||||||
int processId,
|
|
||||||
int id,
|
|
||||||
Material type,
|
|
||||||
String user,
|
|
||||||
Object object) {
|
|
||||||
if (object instanceof Location) {
|
if (object instanceof Location) {
|
||||||
|
|
||||||
Location location = (Location) object;
|
Location location = (Location) object;
|
||||||
Map<Integer, ItemStack[]> containers = Consumer.consumerContainers.get(processId);
|
Map<Integer, ItemStack[]> containers = Consumer.consumerContainers.get(processId);
|
||||||
if (containers.get(id) != null) {
|
if (containers.get(id) != null) {
|
||||||
|
|
||||||
ItemStack[] container = containers.get(id);
|
ItemStack[] container = containers.get(id);
|
||||||
ContainerBreakLogger.log(preparedStmt, batchCount, user, location, type, container);
|
ContainerBreakLogger.log(preparedStmt, batchCount, user, location, type, container);
|
||||||
containers.remove(id);
|
containers.remove(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,65 +19,73 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
class ContainerTransactionProcess {
|
class ContainerTransactionProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmtContainer, PreparedStatement preparedStmtItems, int batchCount,
|
||||||
PreparedStatement preparedStmtContainer,
|
int processId, int id, Material type, int forceData, String user, Object object)
|
||||||
PreparedStatement preparedStmtItems,
|
{
|
||||||
int batchCount,
|
|
||||||
int processId,
|
|
||||||
int id,
|
|
||||||
Material type,
|
|
||||||
int forceData,
|
|
||||||
String user,
|
|
||||||
Object object) {
|
|
||||||
if (object instanceof Location) {
|
if (object instanceof Location) {
|
||||||
|
|
||||||
Location location = (Location) object;
|
Location location = (Location) object;
|
||||||
Map<Integer, Object> inventories = Consumer.consumerInventories.get(processId);
|
Map<Integer, Object> inventories = Consumer.consumerInventories.get(processId);
|
||||||
if (inventories.get(id) != null) {
|
if (inventories.get(id) != null) {
|
||||||
|
|
||||||
Object inventory = inventories.get(id);
|
Object inventory = inventories.get(id);
|
||||||
String transactingChestId = location.getWorld().getUID().toString() + "." + location.getBlockX() + "."
|
String transactingChestId = location.getWorld().getUID().toString() + "." + location.getBlockX() + "."
|
||||||
+ location.getBlockY() + "." + location.getBlockZ();
|
+ location.getBlockY() + "." + location.getBlockZ();
|
||||||
String loggingChestId = user.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "."
|
String loggingChestId = user.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "."
|
||||||
+ location.getBlockY() + "." + location.getBlockZ();
|
+ location.getBlockY() + "." + location.getBlockZ();
|
||||||
if (ConfigHandler.loggingChest.get(loggingChestId) != null) {
|
if (ConfigHandler.loggingChest.get(loggingChestId) != null) {
|
||||||
|
|
||||||
int current_chest = ConfigHandler.loggingChest.get(loggingChestId);
|
int current_chest = ConfigHandler.loggingChest.get(loggingChestId);
|
||||||
if (ConfigHandler.oldContainer.get(loggingChestId) == null) {
|
if (ConfigHandler.oldContainer.get(loggingChestId) == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int force_size = 0;
|
int force_size = 0;
|
||||||
if (ConfigHandler.forceContainer.get(loggingChestId) != null) {
|
if (ConfigHandler.forceContainer.get(loggingChestId) != null) {
|
||||||
force_size =
|
|
||||||
ConfigHandler.forceContainer.get(loggingChestId).size();
|
force_size = ConfigHandler.forceContainer.get(loggingChestId).size();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (current_chest == forceData
|
|
||||||
|| force_size > 0) { // This prevents client side chest sorting mods from messing things up.
|
if (current_chest == forceData || force_size > 0) { // This prevents client side chest sorting mods
|
||||||
ContainerLogger.log(
|
// from messing things up.
|
||||||
preparedStmtContainer, preparedStmtItems, batchCount, user, type, inventory, location);
|
|
||||||
|
ContainerLogger.log(preparedStmtContainer, preparedStmtItems, batchCount, user, type, inventory,
|
||||||
|
location);
|
||||||
List<ItemStack[]> old = ConfigHandler.oldContainer.get(loggingChestId);
|
List<ItemStack[]> old = ConfigHandler.oldContainer.get(loggingChestId);
|
||||||
if (old.size() == 0) {
|
if (old.size() == 0) {
|
||||||
|
|
||||||
ConfigHandler.oldContainer.remove(loggingChestId);
|
ConfigHandler.oldContainer.remove(loggingChestId);
|
||||||
ConfigHandler.loggingChest.remove(loggingChestId);
|
ConfigHandler.loggingChest.remove(loggingChestId);
|
||||||
ConfigHandler.transactingChest.remove(transactingChestId);
|
ConfigHandler.transactingChest.remove(transactingChestId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (loggingChestId.startsWith("#hopper")) {
|
} else if (loggingChestId.startsWith("#hopper")) {
|
||||||
|
|
||||||
List<Object> transactingChest = ConfigHandler.transactingChest.get(transactingChestId);
|
List<Object> transactingChest = ConfigHandler.transactingChest.get(transactingChestId);
|
||||||
if (force_size == 0
|
if (force_size == 0 && ConfigHandler.oldContainer
|
||||||
&& ConfigHandler.oldContainer
|
.getOrDefault(loggingChestId, Collections.synchronizedList(new ArrayList<>()))
|
||||||
.getOrDefault(
|
.size() == 1 && transactingChest != null && transactingChest.isEmpty())
|
||||||
loggingChestId, Collections.synchronizedList(new ArrayList<>()))
|
{
|
||||||
.size()
|
|
||||||
== 1
|
|
||||||
&& transactingChest != null
|
|
||||||
&& transactingChest.isEmpty()) {
|
|
||||||
int loopCount = ConfigHandler.loggingChest.getOrDefault(loggingChestId, 0);
|
int loopCount = ConfigHandler.loggingChest.getOrDefault(loggingChestId, 0);
|
||||||
int maxInventorySize = (99 * 54);
|
int maxInventorySize = (99 * 54);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Inventory checkInventory = (Inventory) inventory;
|
Inventory checkInventory = (Inventory) inventory;
|
||||||
maxInventorySize = checkInventory.getSize() * checkInventory.getMaxStackSize();
|
maxInventorySize = checkInventory.getSize() * checkInventory.getMaxStackSize();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
// use default of 5,346
|
// use default of 5,346
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loopCount > maxInventorySize) {
|
if (loopCount > maxInventorySize) {
|
||||||
|
|
||||||
ItemStack[] destinationContents = null;
|
ItemStack[] destinationContents = null;
|
||||||
ItemStack movedItem = null;
|
ItemStack movedItem = null;
|
||||||
|
|
||||||
@@ -85,28 +93,46 @@ class ContainerTransactionProcess {
|
|||||||
+ "." + location.getBlockZ();
|
+ "." + location.getBlockZ();
|
||||||
Object[] hopperPushData = ConfigHandler.hopperSuccess.remove(hopperPush);
|
Object[] hopperPushData = ConfigHandler.hopperSuccess.remove(hopperPush);
|
||||||
if (hopperPushData != null) {
|
if (hopperPushData != null) {
|
||||||
|
|
||||||
destinationContents = (ItemStack[]) hopperPushData[0];
|
destinationContents = (ItemStack[]) hopperPushData[0];
|
||||||
movedItem = (ItemStack) hopperPushData[1];
|
movedItem = (ItemStack) hopperPushData[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destinationContents != null) {
|
if (destinationContents != null) {
|
||||||
|
|
||||||
Set<ItemStack> movedItems = new HashSet<>();
|
Set<ItemStack> movedItems = new HashSet<>();
|
||||||
Object[] lastAbort = ConfigHandler.hopperAbort.get(hopperPush);
|
Object[] lastAbort = ConfigHandler.hopperAbort.get(hopperPush);
|
||||||
if (lastAbort != null
|
if (lastAbort != null
|
||||||
&& Arrays.equals(destinationContents, (ItemStack[]) lastAbort[1])) {
|
&& Arrays.equals(destinationContents, (ItemStack[]) lastAbort[1]))
|
||||||
|
{
|
||||||
|
|
||||||
((Set<?>) lastAbort[0])
|
((Set<?>) lastAbort[0])
|
||||||
.forEach(itemStack -> movedItems.add((ItemStack) itemStack));
|
.forEach(itemStack -> movedItems.add((ItemStack) itemStack));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
movedItems.add(movedItem);
|
movedItems.add(movedItem);
|
||||||
ConfigHandler.hopperAbort.put(
|
ConfigHandler.hopperAbort.put(hopperPush,
|
||||||
hopperPush, new Object[] {movedItems, destinationContents});
|
new Object[]
|
||||||
|
{ movedItems, destinationContents });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inventories.remove(id);
|
inventories.remove(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,26 +10,39 @@ import net.coreprotect.utility.Chat;
|
|||||||
|
|
||||||
class EntityInsertProcess {
|
class EntityInsertProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, Statement statement, int batchCount, Object name,
|
||||||
PreparedStatement preparedStmt, Statement statement, int batchCount, Object name, int materialId) {
|
int materialId)
|
||||||
|
{
|
||||||
|
|
||||||
if (name instanceof String) {
|
if (name instanceof String) {
|
||||||
String query =
|
|
||||||
"SELECT id FROM " + ConfigHandler.prefix + "entity_map WHERE id = '" + materialId + "' LIMIT 0, 1";
|
String query = "SELECT id FROM " + ConfigHandler.prefix + "entity_map WHERE id = '" + materialId
|
||||||
|
+ "' LIMIT 0, 1";
|
||||||
boolean hasMaterial = MaterialStatement.hasMaterial(statement, query);
|
boolean hasMaterial = MaterialStatement.hasMaterial(statement, query);
|
||||||
if (!hasMaterial) {
|
if (!hasMaterial) {
|
||||||
|
|
||||||
MaterialStatement.insert(preparedStmt, batchCount, materialId, (String) name);
|
MaterialStatement.insert(preparedStmt, batchCount, materialId, (String) name);
|
||||||
|
|
||||||
// validate ID maps to ensure mapping wasn't reloaded from database prior to this insertion completing
|
// validate ID maps to ensure mapping wasn't reloaded from database prior to
|
||||||
|
// this insertion completing
|
||||||
ConfigHandler.entities.put((String) name, materialId);
|
ConfigHandler.entities.put((String) name, materialId);
|
||||||
ConfigHandler.entitiesReversed.put(materialId, (String) name);
|
ConfigHandler.entitiesReversed.put(materialId, (String) name);
|
||||||
if (materialId > ConfigHandler.entityId) {
|
if (materialId > ConfigHandler.entityId) {
|
||||||
|
|
||||||
ConfigHandler.entityId = materialId;
|
ConfigHandler.entityId = materialId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.CACHE_ERROR, "entity"));
|
Chat.console(Phrase.build(Phrase.CACHE_ERROR, "entity"));
|
||||||
Chat.console(Phrase.build(Phrase.CACHE_RELOAD, Selector.FIRST));
|
Chat.console(Phrase.build(Phrase.CACHE_RELOAD, Selector.FIRST));
|
||||||
ConfigHandler.loadTypes(statement);
|
ConfigHandler.loadTypes(statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,24 +11,26 @@ import org.bukkit.entity.EntityType;
|
|||||||
|
|
||||||
class EntityKillProcess {
|
class EntityKillProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, PreparedStatement preparedStmtEntities, int batchCount,
|
||||||
PreparedStatement preparedStmt,
|
int processId, int id, Object object, String user)
|
||||||
PreparedStatement preparedStmtEntities,
|
{
|
||||||
int batchCount,
|
|
||||||
int processId,
|
|
||||||
int id,
|
|
||||||
Object object,
|
|
||||||
String user) {
|
|
||||||
if (object instanceof Object[]) {
|
if (object instanceof Object[]) {
|
||||||
|
|
||||||
BlockState block = (BlockState) ((Object[]) object)[0];
|
BlockState block = (BlockState) ((Object[]) object)[0];
|
||||||
EntityType type = (EntityType) ((Object[]) object)[1];
|
EntityType type = (EntityType) ((Object[]) object)[1];
|
||||||
Map<Integer, List<Object>> objectLists = Consumer.consumerObjectList.get(processId);
|
Map<Integer, List<Object>> objectLists = Consumer.consumerObjectList.get(processId);
|
||||||
if (objectLists.get(id) != null) {
|
if (objectLists.get(id) != null) {
|
||||||
|
|
||||||
List<Object> objectList = objectLists.get(id);
|
List<Object> objectList = objectLists.get(id);
|
||||||
int entityId = Util.getEntityId(type);
|
int entityId = Util.getEntityId(type);
|
||||||
EntityKillLogger.log(preparedStmt, preparedStmtEntities, batchCount, user, block, objectList, entityId);
|
EntityKillLogger.log(preparedStmt, preparedStmtEntities, batchCount, user, block, objectList, entityId);
|
||||||
objectLists.remove(id);
|
objectLists.remove(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,12 +11,17 @@ import org.bukkit.entity.EntityType;
|
|||||||
class EntitySpawnProcess {
|
class EntitySpawnProcess {
|
||||||
|
|
||||||
static void process(Statement statement, Object object, int rowId) {
|
static void process(Statement statement, Object object, int rowId) {
|
||||||
|
|
||||||
if (object instanceof Object[]) {
|
if (object instanceof Object[]) {
|
||||||
|
|
||||||
BlockState block = (BlockState) ((Object[]) object)[0];
|
BlockState block = (BlockState) ((Object[]) object)[0];
|
||||||
EntityType type = (EntityType) ((Object[]) object)[1];
|
EntityType type = (EntityType) ((Object[]) object)[1];
|
||||||
String query = "SELECT data FROM " + ConfigHandler.prefix + "entity WHERE rowid='" + rowId + "' LIMIT 0, 1";
|
String query = "SELECT data FROM " + ConfigHandler.prefix + "entity WHERE rowid='" + rowId + "' LIMIT 0, 1";
|
||||||
List<Object> data = EntityStatement.getData(statement, block, query);
|
List<Object> data = EntityStatement.getData(statement, block, query);
|
||||||
EntityUtil.spawnEntity(block, type, data);
|
EntityUtil.spawnEntity(block, type, data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,22 +9,18 @@ import org.bukkit.Location;
|
|||||||
|
|
||||||
class ItemTransactionProcess extends Queue {
|
class ItemTransactionProcess extends Queue {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, int forceData, int time,
|
||||||
PreparedStatement preparedStmt,
|
int offset, String user, Object object)
|
||||||
int batchCount,
|
{
|
||||||
int processId,
|
|
||||||
int id,
|
|
||||||
int forceData,
|
|
||||||
int time,
|
|
||||||
int offset,
|
|
||||||
String user,
|
|
||||||
Object object) {
|
|
||||||
if (object instanceof Location) {
|
if (object instanceof Location) {
|
||||||
|
|
||||||
Location location = (Location) object;
|
Location location = (Location) object;
|
||||||
String loggingItemId = user.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "."
|
String loggingItemId = user.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "."
|
||||||
+ location.getBlockY() + "." + location.getBlockZ();
|
+ location.getBlockY() + "." + location.getBlockZ();
|
||||||
|
|
||||||
if (ConfigHandler.loggingItem.get(loggingItemId) != null) {
|
if (ConfigHandler.loggingItem.get(loggingItemId) != null) {
|
||||||
|
|
||||||
int current_chest = ConfigHandler.loggingItem.get(loggingItemId);
|
int current_chest = ConfigHandler.loggingItem.get(loggingItemId);
|
||||||
if (ConfigHandler.itemsPickup.get(loggingItemId) == null
|
if (ConfigHandler.itemsPickup.get(loggingItemId) == null
|
||||||
&& ConfigHandler.itemsDrop.get(loggingItemId) == null
|
&& ConfigHandler.itemsDrop.get(loggingItemId) == null
|
||||||
@@ -34,12 +30,18 @@ class ItemTransactionProcess extends Queue {
|
|||||||
&& ConfigHandler.itemsDestroy.get(loggingItemId) == null
|
&& ConfigHandler.itemsDestroy.get(loggingItemId) == null
|
||||||
&& ConfigHandler.itemsCreate.get(loggingItemId) == null
|
&& ConfigHandler.itemsCreate.get(loggingItemId) == null
|
||||||
&& ConfigHandler.itemsSell.get(loggingItemId) == null
|
&& ConfigHandler.itemsSell.get(loggingItemId) == null
|
||||||
&& ConfigHandler.itemsBuy.get(loggingItemId) == null) {
|
&& ConfigHandler.itemsBuy.get(loggingItemId) == null)
|
||||||
|
{
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_chest == forceData) {
|
if (current_chest == forceData) {
|
||||||
|
|
||||||
int currentTime = (int) (System.currentTimeMillis() / 1000L);
|
int currentTime = (int) (System.currentTimeMillis() / 1000L);
|
||||||
if (currentTime > time) {
|
if (currentTime > time) {
|
||||||
|
|
||||||
ItemLogger.log(preparedStmt, batchCount, location, offset, user);
|
ItemLogger.log(preparedStmt, batchCount, location, offset, user);
|
||||||
ConfigHandler.itemsPickup.remove(loggingItemId);
|
ConfigHandler.itemsPickup.remove(loggingItemId);
|
||||||
ConfigHandler.itemsDrop.remove(loggingItemId);
|
ConfigHandler.itemsDrop.remove(loggingItemId);
|
||||||
@@ -51,11 +53,19 @@ class ItemTransactionProcess extends Queue {
|
|||||||
ConfigHandler.itemsSell.remove(loggingItemId);
|
ConfigHandler.itemsSell.remove(loggingItemId);
|
||||||
ConfigHandler.itemsBuy.remove(loggingItemId);
|
ConfigHandler.itemsBuy.remove(loggingItemId);
|
||||||
ConfigHandler.loggingItem.remove(loggingItemId);
|
ConfigHandler.loggingItem.remove(loggingItemId);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Queue.queueItemTransaction(user, location, time, offset, forceData);
|
Queue.queueItemTransaction(user, location, time, offset, forceData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,26 +10,39 @@ import net.coreprotect.utility.Chat;
|
|||||||
|
|
||||||
class MaterialInsertProcess {
|
class MaterialInsertProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, Statement statement, int batchCount, Object name,
|
||||||
PreparedStatement preparedStmt, Statement statement, int batchCount, Object name, int materialId) {
|
int materialId)
|
||||||
|
{
|
||||||
|
|
||||||
if (name instanceof String) {
|
if (name instanceof String) {
|
||||||
|
|
||||||
String query = "SELECT id FROM " + ConfigHandler.prefix + "material_map WHERE id = '" + materialId
|
String query = "SELECT id FROM " + ConfigHandler.prefix + "material_map WHERE id = '" + materialId
|
||||||
+ "' LIMIT 0, 1";
|
+ "' LIMIT 0, 1";
|
||||||
boolean hasMaterial = MaterialStatement.hasMaterial(statement, query);
|
boolean hasMaterial = MaterialStatement.hasMaterial(statement, query);
|
||||||
if (!hasMaterial) {
|
if (!hasMaterial) {
|
||||||
|
|
||||||
MaterialStatement.insert(preparedStmt, batchCount, materialId, (String) name);
|
MaterialStatement.insert(preparedStmt, batchCount, materialId, (String) name);
|
||||||
|
|
||||||
// validate ID maps to ensure mapping wasn't reloaded from database prior to this insertion completing
|
// validate ID maps to ensure mapping wasn't reloaded from database prior to
|
||||||
|
// this insertion completing
|
||||||
ConfigHandler.materials.put((String) name, materialId);
|
ConfigHandler.materials.put((String) name, materialId);
|
||||||
ConfigHandler.materialsReversed.put(materialId, (String) name);
|
ConfigHandler.materialsReversed.put(materialId, (String) name);
|
||||||
if (materialId > ConfigHandler.materialId) {
|
if (materialId > ConfigHandler.materialId) {
|
||||||
|
|
||||||
ConfigHandler.materialId = materialId;
|
ConfigHandler.materialId = materialId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.CACHE_ERROR, "material"));
|
Chat.console(Phrase.build(Phrase.CACHE_ERROR, "material"));
|
||||||
Chat.console(Phrase.build(Phrase.CACHE_RELOAD, Selector.FIRST));
|
Chat.console(Phrase.build(Phrase.CACHE_RELOAD, Selector.FIRST));
|
||||||
ConfigHandler.loadTypes(statement);
|
ConfigHandler.loadTypes(statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,40 +13,36 @@ import org.bukkit.block.BlockState;
|
|||||||
|
|
||||||
class NaturalBlockBreakProcess {
|
class NaturalBlockBreakProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(Statement statement, PreparedStatement preparedStmt, int batchCount, int processId, int id,
|
||||||
Statement statement,
|
String user, Object object, Material blockType, int blockData, String overrideData)
|
||||||
PreparedStatement preparedStmt,
|
{
|
||||||
int batchCount,
|
|
||||||
int processId,
|
|
||||||
int id,
|
|
||||||
String user,
|
|
||||||
Object object,
|
|
||||||
Material blockType,
|
|
||||||
int blockData,
|
|
||||||
String overrideData) {
|
|
||||||
if (object instanceof BlockState) {
|
if (object instanceof BlockState) {
|
||||||
|
|
||||||
BlockState block = (BlockState) object;
|
BlockState block = (BlockState) object;
|
||||||
Map<Integer, List<BlockState>> blockLists = Consumer.consumerBlockList.get(processId);
|
Map<Integer, List<BlockState>> blockLists = Consumer.consumerBlockList.get(processId);
|
||||||
if (blockLists.get(id) != null) {
|
if (blockLists.get(id) != null) {
|
||||||
|
|
||||||
List<BlockState> blockStateList = blockLists.get(id);
|
List<BlockState> blockStateList = blockLists.get(id);
|
||||||
for (BlockState blockState : blockStateList) {
|
for (BlockState blockState : blockStateList) {
|
||||||
|
|
||||||
String removed = Lookup.whoRemovedCache(blockState);
|
String removed = Lookup.whoRemovedCache(blockState);
|
||||||
if (removed.length() > 0) {
|
if (removed.length() > 0) {
|
||||||
|
|
||||||
user = removed;
|
user = removed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blockLists.remove(id);
|
blockLists.remove(id);
|
||||||
BlockBreakLogger.log(
|
BlockBreakLogger.log(preparedStmt, batchCount, user, block.getLocation(), Util.getBlockId(blockType),
|
||||||
preparedStmt,
|
blockData, null, block.getBlockData().getAsString(), overrideData);
|
||||||
batchCount,
|
|
||||||
user,
|
|
||||||
block.getLocation(),
|
|
||||||
Util.getBlockId(blockType),
|
|
||||||
blockData,
|
|
||||||
null,
|
|
||||||
block.getBlockData().getAsString(),
|
|
||||||
overrideData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,22 +8,32 @@ import org.bukkit.Location;
|
|||||||
|
|
||||||
class PlayerChatProcess {
|
class PlayerChatProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Object object,
|
||||||
PreparedStatement preparedStmt, int batchCount, int processId, int id, Object object, String user) {
|
String user)
|
||||||
|
{
|
||||||
|
|
||||||
if (!(object instanceof Object[])) {
|
if (!(object instanceof Object[])) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object[] data = (Object[]) object;
|
Object[] data = (Object[]) object;
|
||||||
if (data[1] instanceof Location) {
|
if (data[1] instanceof Location) {
|
||||||
|
|
||||||
Map<Integer, String> strings = Consumer.consumerStrings.get(processId);
|
Map<Integer, String> strings = Consumer.consumerStrings.get(processId);
|
||||||
if (strings.get(id) != null) {
|
if (strings.get(id) != null) {
|
||||||
|
|
||||||
String message = strings.get(id);
|
String message = strings.get(id);
|
||||||
Long timestamp = (Long) data[0];
|
Long timestamp = (Long) data[0];
|
||||||
Location location = (Location) data[1];
|
Location location = (Location) data[1];
|
||||||
ChatLogger.log(preparedStmt, batchCount, timestamp, location, user, message);
|
ChatLogger.log(preparedStmt, batchCount, timestamp, location, user, message);
|
||||||
strings.remove(id);
|
strings.remove(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,22 +8,32 @@ import org.bukkit.Location;
|
|||||||
|
|
||||||
class PlayerCommandProcess {
|
class PlayerCommandProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, Object object,
|
||||||
PreparedStatement preparedStmt, int batchCount, int processId, int id, Object object, String user) {
|
String user)
|
||||||
|
{
|
||||||
|
|
||||||
if (!(object instanceof Object[])) {
|
if (!(object instanceof Object[])) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object[] data = (Object[]) object;
|
Object[] data = (Object[]) object;
|
||||||
if (data[1] instanceof Location) {
|
if (data[1] instanceof Location) {
|
||||||
|
|
||||||
Map<Integer, String> strings = Consumer.consumerStrings.get(processId);
|
Map<Integer, String> strings = Consumer.consumerStrings.get(processId);
|
||||||
if (strings.get(id) != null) {
|
if (strings.get(id) != null) {
|
||||||
|
|
||||||
String message = strings.get(id);
|
String message = strings.get(id);
|
||||||
Long timestamp = (Long) data[0];
|
Long timestamp = (Long) data[0];
|
||||||
Location location = (Location) data[1];
|
Location location = (Location) data[1];
|
||||||
CommandLogger.log(preparedStmt, batchCount, timestamp, location, user, message);
|
CommandLogger.log(preparedStmt, batchCount, timestamp, location, user, message);
|
||||||
strings.remove(id);
|
strings.remove(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,9 +8,14 @@ import org.bukkit.block.BlockState;
|
|||||||
class PlayerInteractionProcess {
|
class PlayerInteractionProcess {
|
||||||
|
|
||||||
static void process(PreparedStatement preparedStmt, int batchCount, String user, Object object, Material type) {
|
static void process(PreparedStatement preparedStmt, int batchCount, String user, Object object, Material type) {
|
||||||
|
|
||||||
if (object instanceof BlockState) {
|
if (object instanceof BlockState) {
|
||||||
|
|
||||||
BlockState block = (BlockState) object;
|
BlockState block = (BlockState) object;
|
||||||
PlayerInteractLogger.log(preparedStmt, batchCount, user, block, type);
|
PlayerInteractLogger.log(preparedStmt, batchCount, user, block, type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,10 +7,15 @@ import org.bukkit.block.BlockState;
|
|||||||
class PlayerKillProcess {
|
class PlayerKillProcess {
|
||||||
|
|
||||||
static void process(PreparedStatement preparedStmt, int batchCount, int id, Object object, String user) {
|
static void process(PreparedStatement preparedStmt, int batchCount, int id, Object object, String user) {
|
||||||
|
|
||||||
if (object instanceof Object[]) {
|
if (object instanceof Object[]) {
|
||||||
|
|
||||||
BlockState block = (BlockState) ((Object[]) object)[0];
|
BlockState block = (BlockState) ((Object[]) object)[0];
|
||||||
String player = (String) ((Object[]) object)[1];
|
String player = (String) ((Object[]) object)[1];
|
||||||
PlayerKillLogger.log(preparedStmt, batchCount, user, block, player);
|
PlayerKillLogger.log(preparedStmt, batchCount, user, block, player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,28 +10,30 @@ import org.bukkit.Location;
|
|||||||
|
|
||||||
class PlayerLoginProcess {
|
class PlayerLoginProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(Connection connection, PreparedStatement preparedStmt, int batchCount, int processId, int id,
|
||||||
Connection connection,
|
Object object, int configSessions, int configUsernames, int time, String user)
|
||||||
PreparedStatement preparedStmt,
|
{
|
||||||
int batchCount,
|
|
||||||
int processId,
|
|
||||||
int id,
|
|
||||||
Object object,
|
|
||||||
int configSessions,
|
|
||||||
int configUsernames,
|
|
||||||
int time,
|
|
||||||
String user) {
|
|
||||||
if (object instanceof Location) {
|
if (object instanceof Location) {
|
||||||
|
|
||||||
Map<Integer, String> strings = Consumer.consumerStrings.get(processId);
|
Map<Integer, String> strings = Consumer.consumerStrings.get(processId);
|
||||||
if (strings.get(id) != null) {
|
if (strings.get(id) != null) {
|
||||||
|
|
||||||
String uuid = strings.get(id);
|
String uuid = strings.get(id);
|
||||||
Location location = (Location) object;
|
Location location = (Location) object;
|
||||||
UsernameLogger.log(connection, user, uuid, configUsernames, time);
|
UsernameLogger.log(connection, user, uuid, configUsernames, time);
|
||||||
if (configSessions == 1) {
|
if (configSessions == 1) {
|
||||||
|
|
||||||
PlayerSessionLogger.log(preparedStmt, batchCount, user, location, time, 1);
|
PlayerSessionLogger.log(preparedStmt, batchCount, user, location, time, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strings.remove(id);
|
strings.remove(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,14 @@ import org.bukkit.Location;
|
|||||||
class PlayerLogoutProcess {
|
class PlayerLogoutProcess {
|
||||||
|
|
||||||
static void process(PreparedStatement preparedStmt, int batchCount, Object object, int time, String user) {
|
static void process(PreparedStatement preparedStmt, int batchCount, Object object, int time, String user) {
|
||||||
|
|
||||||
if (object instanceof Location) {
|
if (object instanceof Location) {
|
||||||
|
|
||||||
Location location = (Location) object;
|
Location location = (Location) object;
|
||||||
PlayerSessionLogger.log(preparedStmt, batchCount, user, location, time, 0);
|
PlayerSessionLogger.log(preparedStmt, batchCount, user, location, time, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -49,27 +49,41 @@ public class Process {
|
|||||||
private static volatile int currentConsumerSize = 0;
|
private static volatile int currentConsumerSize = 0;
|
||||||
|
|
||||||
public static int getCurrentConsumerSize() {
|
public static int getCurrentConsumerSize() {
|
||||||
|
|
||||||
return currentConsumerSize;
|
return currentConsumerSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void updateLockTable(Statement statement, int locked) {
|
protected static void updateLockTable(Statement statement, int locked) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
int unixTimestamp = (int) (System.currentTimeMillis() / 1000L);
|
int unixTimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||||
int timeSinceLastUpdate = unixTimestamp - lastLockUpdate;
|
int timeSinceLastUpdate = unixTimestamp - lastLockUpdate;
|
||||||
if (timeSinceLastUpdate >= 15 || locked == 0) {
|
if (timeSinceLastUpdate >= 15 || locked == 0) {
|
||||||
|
|
||||||
statement.executeUpdate("UPDATE " + ConfigHandler.prefix + "database_lock SET status = '" + locked
|
statement.executeUpdate("UPDATE " + ConfigHandler.prefix + "database_lock SET status = '" + locked
|
||||||
+ "', time = '" + unixTimestamp + "' WHERE rowid = '1'");
|
+ "', time = '" + unixTimestamp + "' WHERE rowid = '1'");
|
||||||
lastLockUpdate = unixTimestamp;
|
lastLockUpdate = unixTimestamp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void processConsumer(int processId, boolean lastRun) {
|
protected static void processConsumer(int processId, boolean lastRun) {
|
||||||
|
|
||||||
try (Connection connection = Database.getConnection(false, 500)) {
|
try (Connection connection = Database.getConnection(false, 500)) {
|
||||||
|
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
@@ -83,25 +97,34 @@ public class Process {
|
|||||||
currentConsumerSize = consumerDataSize;
|
currentConsumerSize = consumerDataSize;
|
||||||
|
|
||||||
if (currentConsumerSize == 0) { // No data, skip processing
|
if (currentConsumerSize == 0) { // No data, skip processing
|
||||||
|
|
||||||
updateLockTable(statement, (lastRun ? 0 : 1));
|
updateLockTable(statement, (lastRun ? 0 : 1));
|
||||||
statement.close();
|
statement.close();
|
||||||
Consumer.consumer_id.put(processId, new Integer[] {0, 0});
|
Consumer.consumer_id.put(processId, new Integer[] { 0, 0 });
|
||||||
Consumer.isPaused = false;
|
Consumer.isPaused = false;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
// Scan through usernames, ensure everything is loaded in memory.
|
// Scan through usernames, ensure everything is loaded in memory.
|
||||||
for (Entry<Integer, String[]> entry : users.entrySet()) {
|
for (Entry<Integer, String[]> entry : users.entrySet()) {
|
||||||
|
|
||||||
String[] data = entry.getValue();
|
String[] data = entry.getValue();
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
|
|
||||||
String user = data[0];
|
String user = data[0];
|
||||||
String uuid = data[1];
|
String uuid = data[1];
|
||||||
if (user != null && ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT)) == null) {
|
if (user != null && ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT)) == null) {
|
||||||
|
|
||||||
UserStatement.loadId(connection, user, uuid);
|
UserStatement.loadId(connection, user, uuid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLockTable(statement, (lastRun ? 0 : 1));
|
updateLockTable(statement, (lastRun ? 0 : 1));
|
||||||
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
|
|
||||||
@@ -124,8 +147,10 @@ public class Process {
|
|||||||
// Scan through consumer data
|
// Scan through consumer data
|
||||||
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
for (int i = 0; i < consumerDataSize; i++) {
|
for (int i = 0; i < consumerDataSize; i++) {
|
||||||
|
|
||||||
Object[] data = consumerData.get(i);
|
Object[] data = consumerData.get(i);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
|
|
||||||
int id = (int) data[0];
|
int id = (int) data[0];
|
||||||
int action = (int) data[1];
|
int action = (int) data[1];
|
||||||
Material blockType = (Material) data[2];
|
Material blockType = (Material) data[2];
|
||||||
@@ -135,87 +160,46 @@ public class Process {
|
|||||||
int forceData = (int) data[6];
|
int forceData = (int) data[6];
|
||||||
|
|
||||||
if (users.get(id) != null && consumerObject.get(id) != null) {
|
if (users.get(id) != null && consumerObject.get(id) != null) {
|
||||||
|
|
||||||
String user = users.get(id)[0];
|
String user = users.get(id)[0];
|
||||||
Object object = consumerObject.get(id);
|
Object object = consumerObject.get(id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
|
||||||
case Process.BLOCK_BREAK:
|
case Process.BLOCK_BREAK:
|
||||||
BlockBreakProcess.process(
|
BlockBreakProcess.process(preparedStmtBlocks, preparedStmtSkulls, i, processId, id,
|
||||||
preparedStmtBlocks,
|
blockType, blockData, replaceType, forceData, user, object,
|
||||||
preparedStmtSkulls,
|
|
||||||
i,
|
|
||||||
processId,
|
|
||||||
id,
|
|
||||||
blockType,
|
|
||||||
blockData,
|
|
||||||
replaceType,
|
|
||||||
forceData,
|
|
||||||
user,
|
|
||||||
object,
|
|
||||||
(String) data[7]);
|
(String) data[7]);
|
||||||
break;
|
break;
|
||||||
case Process.BLOCK_PLACE:
|
case Process.BLOCK_PLACE:
|
||||||
BlockPlaceProcess.process(
|
BlockPlaceProcess.process(preparedStmtBlocks, preparedStmtSkulls, i, blockType,
|
||||||
preparedStmtBlocks,
|
blockData, replaceType, replaceData, forceData, user, object,
|
||||||
preparedStmtSkulls,
|
(String) data[7], (String) data[8]);
|
||||||
i,
|
|
||||||
blockType,
|
|
||||||
blockData,
|
|
||||||
replaceType,
|
|
||||||
replaceData,
|
|
||||||
forceData,
|
|
||||||
user,
|
|
||||||
object,
|
|
||||||
(String) data[7],
|
|
||||||
(String) data[8]);
|
|
||||||
break;
|
break;
|
||||||
case Process.SIGN_TEXT:
|
case Process.SIGN_TEXT:
|
||||||
SignTextProcess.process(
|
SignTextProcess.process(preparedStmtSigns, i, processId, id, forceData, user,
|
||||||
preparedStmtSigns,
|
object, replaceData, blockData);
|
||||||
i,
|
|
||||||
processId,
|
|
||||||
id,
|
|
||||||
forceData,
|
|
||||||
user,
|
|
||||||
object,
|
|
||||||
replaceData,
|
|
||||||
blockData);
|
|
||||||
break;
|
break;
|
||||||
case Process.CONTAINER_BREAK:
|
case Process.CONTAINER_BREAK:
|
||||||
ContainerBreakProcess.process(
|
ContainerBreakProcess.process(preparedStmtContainers, i, processId, id, blockType,
|
||||||
preparedStmtContainers, i, processId, id, blockType, user, object);
|
user, object);
|
||||||
break;
|
break;
|
||||||
case Process.PLAYER_INTERACTION:
|
case Process.PLAYER_INTERACTION:
|
||||||
PlayerInteractionProcess.process(preparedStmtBlocks, i, user, object, blockType);
|
PlayerInteractionProcess.process(preparedStmtBlocks, i, user, object, blockType);
|
||||||
break;
|
break;
|
||||||
case Process.CONTAINER_TRANSACTION:
|
case Process.CONTAINER_TRANSACTION:
|
||||||
ContainerTransactionProcess.process(
|
ContainerTransactionProcess.process(preparedStmtContainers, preparedStmtItems, i,
|
||||||
preparedStmtContainers,
|
processId, id, blockType, forceData, user, object);
|
||||||
preparedStmtItems,
|
|
||||||
i,
|
|
||||||
processId,
|
|
||||||
id,
|
|
||||||
blockType,
|
|
||||||
forceData,
|
|
||||||
user,
|
|
||||||
object);
|
|
||||||
break;
|
break;
|
||||||
case Process.ITEM_TRANSACTION:
|
case Process.ITEM_TRANSACTION:
|
||||||
ItemTransactionProcess.process(
|
ItemTransactionProcess.process(preparedStmtItems, i, processId, id, forceData,
|
||||||
preparedStmtItems,
|
replaceData, blockData, user, object);
|
||||||
i,
|
|
||||||
processId,
|
|
||||||
id,
|
|
||||||
forceData,
|
|
||||||
replaceData,
|
|
||||||
blockData,
|
|
||||||
user,
|
|
||||||
object);
|
|
||||||
break;
|
break;
|
||||||
case Process.STRUCTURE_GROWTH:
|
case Process.STRUCTURE_GROWTH:
|
||||||
StructureGrowthProcess.process(
|
StructureGrowthProcess.process(statement, preparedStmtBlocks, i, processId, id,
|
||||||
statement, preparedStmtBlocks, i, processId, id, user, object, forceData);
|
user, object, forceData);
|
||||||
break;
|
break;
|
||||||
case Process.ROLLBACK_UPDATE:
|
case Process.ROLLBACK_UPDATE:
|
||||||
RollbackUpdateProcess.process(statement, processId, id, forceData, 0);
|
RollbackUpdateProcess.process(statement, processId, id, forceData, 0);
|
||||||
@@ -248,44 +232,26 @@ public class Process {
|
|||||||
PlayerCommandProcess.process(preparedStmtCommand, i, processId, id, object, user);
|
PlayerCommandProcess.process(preparedStmtCommand, i, processId, id, object, user);
|
||||||
break;
|
break;
|
||||||
case Process.PLAYER_LOGIN:
|
case Process.PLAYER_LOGIN:
|
||||||
PlayerLoginProcess.process(
|
PlayerLoginProcess.process(connection, preparedStmtSession, i, processId, id,
|
||||||
connection,
|
object, blockData, replaceData, forceData, user);
|
||||||
preparedStmtSession,
|
|
||||||
i,
|
|
||||||
processId,
|
|
||||||
id,
|
|
||||||
object,
|
|
||||||
blockData,
|
|
||||||
replaceData,
|
|
||||||
forceData,
|
|
||||||
user);
|
|
||||||
break;
|
break;
|
||||||
case Process.PLAYER_LOGOUT:
|
case Process.PLAYER_LOGOUT:
|
||||||
PlayerLogoutProcess.process(preparedStmtSession, i, object, forceData, user);
|
PlayerLogoutProcess.process(preparedStmtSession, i, object, forceData, user);
|
||||||
break;
|
break;
|
||||||
case Process.ENTITY_KILL:
|
case Process.ENTITY_KILL:
|
||||||
EntityKillProcess.process(
|
EntityKillProcess.process(preparedStmtBlocks, preparedStmtEntities, i, processId,
|
||||||
preparedStmtBlocks, preparedStmtEntities, i, processId, id, object, user);
|
id, object, user);
|
||||||
break;
|
break;
|
||||||
case Process.ENTITY_SPAWN:
|
case Process.ENTITY_SPAWN:
|
||||||
EntitySpawnProcess.process(statement, object, forceData);
|
EntitySpawnProcess.process(statement, object, forceData);
|
||||||
break;
|
break;
|
||||||
case Process.NATURAL_BLOCK_BREAK:
|
case Process.NATURAL_BLOCK_BREAK:
|
||||||
NaturalBlockBreakProcess.process(
|
NaturalBlockBreakProcess.process(statement, preparedStmtBlocks, i, processId, id,
|
||||||
statement,
|
user, object, blockType, blockData, (String) data[7]);
|
||||||
preparedStmtBlocks,
|
|
||||||
i,
|
|
||||||
processId,
|
|
||||||
id,
|
|
||||||
user,
|
|
||||||
object,
|
|
||||||
blockType,
|
|
||||||
blockData,
|
|
||||||
(String) data[7]);
|
|
||||||
break;
|
break;
|
||||||
case Process.MATERIAL_INSERT:
|
case Process.MATERIAL_INSERT:
|
||||||
MaterialInsertProcess.process(
|
MaterialInsertProcess.process(preparedStmtMaterials, statement, i, object,
|
||||||
preparedStmtMaterials, statement, i, object, forceData);
|
forceData);
|
||||||
break;
|
break;
|
||||||
case Process.ART_INSERT:
|
case Process.ART_INSERT:
|
||||||
ArtInsertProcess.process(preparedStmtArt, statement, i, object, forceData);
|
ArtInsertProcess.process(preparedStmtArt, statement, i, object, forceData);
|
||||||
@@ -297,67 +263,60 @@ public class Process {
|
|||||||
PlayerKillProcess.process(preparedStmtBlocks, i, id, object, user);
|
PlayerKillProcess.process(preparedStmtBlocks, i, id, object, user);
|
||||||
break;
|
break;
|
||||||
case Process.BLOCKDATA_INSERT:
|
case Process.BLOCKDATA_INSERT:
|
||||||
BlockDataInsertProcess.process(
|
BlockDataInsertProcess.process(preparedStmtBlockdata, statement, i, object,
|
||||||
preparedStmtBlockdata, statement, i, object, forceData);
|
forceData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If database connection goes missing, remove processed data from consumer and abort
|
// If database connection goes missing, remove processed data from consumer and
|
||||||
|
// abort
|
||||||
if (statement.isClosed()) {
|
if (statement.isClosed()) {
|
||||||
|
|
||||||
for (int index = (i - 1); index >= 0; index--) {
|
for (int index = (i - 1); index >= 0; index--) {
|
||||||
|
|
||||||
consumerData.remove(index);
|
consumerData.remove(index);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentConsumerSize = 0;
|
currentConsumerSize = 0;
|
||||||
Consumer.consumer_id.put(processId, new Integer[] {0, 0});
|
Consumer.consumer_id.put(processId, new Integer[] { 0, 0 });
|
||||||
Consumer.isPaused = false;
|
Consumer.isPaused = false;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If interrupt requested, commit data, sleep, and resume processing
|
// If interrupt requested, commit data, sleep, and resume processing
|
||||||
if (Consumer.interrupt) {
|
if (Consumer.interrupt) {
|
||||||
commit(
|
|
||||||
statement,
|
commit(statement, preparedStmtSigns, preparedStmtBlocks, preparedStmtSkulls,
|
||||||
preparedStmtSigns,
|
preparedStmtContainers, preparedStmtItems, preparedStmtWorlds, preparedStmtChat,
|
||||||
preparedStmtBlocks,
|
preparedStmtCommand, preparedStmtSession, preparedStmtEntities,
|
||||||
preparedStmtSkulls,
|
preparedStmtMaterials, preparedStmtArt, preparedStmtEntity,
|
||||||
preparedStmtContainers,
|
|
||||||
preparedStmtItems,
|
|
||||||
preparedStmtWorlds,
|
|
||||||
preparedStmtChat,
|
|
||||||
preparedStmtCommand,
|
|
||||||
preparedStmtSession,
|
|
||||||
preparedStmtEntities,
|
|
||||||
preparedStmtMaterials,
|
|
||||||
preparedStmtArt,
|
|
||||||
preparedStmtEntity,
|
|
||||||
preparedStmtBlockdata);
|
preparedStmtBlockdata);
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentConsumerSize--;
|
currentConsumerSize--;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit data to database
|
// commit data to database
|
||||||
commit(
|
commit(statement, preparedStmtSigns, preparedStmtBlocks, preparedStmtSkulls, preparedStmtContainers,
|
||||||
statement,
|
preparedStmtItems, preparedStmtWorlds, preparedStmtChat, preparedStmtCommand, preparedStmtSession,
|
||||||
preparedStmtSigns,
|
preparedStmtEntities, preparedStmtMaterials, preparedStmtArt, preparedStmtEntity,
|
||||||
preparedStmtBlocks,
|
|
||||||
preparedStmtSkulls,
|
|
||||||
preparedStmtContainers,
|
|
||||||
preparedStmtItems,
|
|
||||||
preparedStmtWorlds,
|
|
||||||
preparedStmtChat,
|
|
||||||
preparedStmtCommand,
|
|
||||||
preparedStmtSession,
|
|
||||||
preparedStmtEntities,
|
|
||||||
preparedStmtMaterials,
|
|
||||||
preparedStmtArt,
|
|
||||||
preparedStmtEntity,
|
|
||||||
preparedStmtBlockdata);
|
preparedStmtBlockdata);
|
||||||
|
|
||||||
// close connections/statements
|
// close connections/statements
|
||||||
@@ -381,31 +340,30 @@ public class Process {
|
|||||||
users.clear();
|
users.clear();
|
||||||
consumerObject.clear();
|
consumerObject.clear();
|
||||||
consumerData.clear();
|
consumerData.clear();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Consumer.consumer_id.put(processId, new Integer[] {0, 0});
|
Consumer.consumer_id.put(processId, new Integer[] { 0, 0 });
|
||||||
Consumer.isPaused = false;
|
Consumer.isPaused = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void commit(
|
private static void commit(Statement statement, PreparedStatement preparedStmtSigns,
|
||||||
Statement statement,
|
PreparedStatement preparedStmtBlocks, PreparedStatement preparedStmtSkulls,
|
||||||
PreparedStatement preparedStmtSigns,
|
PreparedStatement preparedStmtContainers, PreparedStatement preparedStmtItems,
|
||||||
PreparedStatement preparedStmtBlocks,
|
PreparedStatement preparedStmtWorlds, PreparedStatement preparedStmtChat,
|
||||||
PreparedStatement preparedStmtSkulls,
|
PreparedStatement preparedStmtCommand, PreparedStatement preparedStmtSession,
|
||||||
PreparedStatement preparedStmtContainers,
|
PreparedStatement preparedStmtEntities, PreparedStatement preparedStmtMaterials,
|
||||||
PreparedStatement preparedStmtItems,
|
PreparedStatement preparedStmtArt, PreparedStatement preparedStmtEntity,
|
||||||
PreparedStatement preparedStmtWorlds,
|
PreparedStatement preparedStmtBlockdata)
|
||||||
PreparedStatement preparedStmtChat,
|
{
|
||||||
PreparedStatement preparedStmtCommand,
|
|
||||||
PreparedStatement preparedStmtSession,
|
|
||||||
PreparedStatement preparedStmtEntities,
|
|
||||||
PreparedStatement preparedStmtMaterials,
|
|
||||||
PreparedStatement preparedStmtArt,
|
|
||||||
PreparedStatement preparedStmtEntity,
|
|
||||||
PreparedStatement preparedStmtBlockdata) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
preparedStmtSigns.executeBatch();
|
preparedStmtSigns.executeBatch();
|
||||||
preparedStmtBlocks.executeBatch();
|
preparedStmtBlocks.executeBatch();
|
||||||
preparedStmtSkulls.executeBatch();
|
preparedStmtSkulls.executeBatch();
|
||||||
@@ -421,8 +379,13 @@ public class Process {
|
|||||||
preparedStmtEntity.executeBatch();
|
preparedStmtEntity.executeBatch();
|
||||||
preparedStmtBlockdata.executeBatch();
|
preparedStmtBlockdata.executeBatch();
|
||||||
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,18 +10,28 @@ import net.coreprotect.utility.Util;
|
|||||||
class RollbackUpdateProcess {
|
class RollbackUpdateProcess {
|
||||||
|
|
||||||
static void process(Statement statement, int processId, int id, int action, int table) {
|
static void process(Statement statement, int processId, int id, int action, int table) {
|
||||||
|
|
||||||
Map<Integer, List<Object[]>> updateLists = Consumer.consumerObjectArrayList.get(processId);
|
Map<Integer, List<Object[]>> updateLists = Consumer.consumerObjectArrayList.get(processId);
|
||||||
if (updateLists.get(id) != null) {
|
if (updateLists.get(id) != null) {
|
||||||
|
|
||||||
List<Object[]> list = updateLists.get(id);
|
List<Object[]> list = updateLists.get(id);
|
||||||
for (Object[] listRow : list) {
|
for (Object[] listRow : list) {
|
||||||
|
|
||||||
long rowid = (Long) listRow[0];
|
long rowid = (Long) listRow[0];
|
||||||
int rolledBack = (Integer) listRow[9];
|
int rolledBack = (Integer) listRow[9];
|
||||||
if (Util.rolledBack(rolledBack, (table == 2 || table == 3 || table == 4))
|
if (Util.rolledBack(rolledBack, (table == 2 || table == 3 || table == 4)) == action) { // 1 = restore, 0
|
||||||
== action) { // 1 = restore, 0 = rollback
|
// = rollback
|
||||||
|
|
||||||
Database.performUpdate(statement, rowid, rolledBack, table);
|
Database.performUpdate(statement, rowid, rolledBack, table);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLists.remove(id);
|
updateLists.remove(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,43 +8,27 @@ import org.bukkit.Location;
|
|||||||
|
|
||||||
class SignTextProcess {
|
class SignTextProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, int forceData,
|
||||||
PreparedStatement preparedStmt,
|
String user, Object object, int action, int color)
|
||||||
int batchCount,
|
{
|
||||||
int processId,
|
|
||||||
int id,
|
|
||||||
int forceData,
|
|
||||||
String user,
|
|
||||||
Object object,
|
|
||||||
int action,
|
|
||||||
int color) {
|
|
||||||
if (object instanceof Location) {
|
if (object instanceof Location) {
|
||||||
|
|
||||||
Location location = (Location) object;
|
Location location = (Location) object;
|
||||||
Map<Integer, Object[]> signs = Consumer.consumerSigns.get(processId);
|
Map<Integer, Object[]> signs = Consumer.consumerSigns.get(processId);
|
||||||
if (signs.get(id) != null) {
|
if (signs.get(id) != null) {
|
||||||
|
|
||||||
Object[] SIGN_DATA = signs.get(id);
|
Object[] SIGN_DATA = signs.get(id);
|
||||||
SignTextLogger.log(
|
SignTextLogger.log(preparedStmt, batchCount, user, location, action, color, (Integer) SIGN_DATA[0],
|
||||||
preparedStmt,
|
(Integer) SIGN_DATA[1], (Boolean) SIGN_DATA[2], (Boolean) SIGN_DATA[3], (String) SIGN_DATA[4],
|
||||||
batchCount,
|
(String) SIGN_DATA[5], (String) SIGN_DATA[6], (String) SIGN_DATA[7], (String) SIGN_DATA[8],
|
||||||
user,
|
(String) SIGN_DATA[9], (String) SIGN_DATA[10], (String) SIGN_DATA[11], forceData);
|
||||||
location,
|
|
||||||
action,
|
|
||||||
color,
|
|
||||||
(Integer) SIGN_DATA[0],
|
|
||||||
(Integer) SIGN_DATA[1],
|
|
||||||
(Boolean) SIGN_DATA[2],
|
|
||||||
(Boolean) SIGN_DATA[3],
|
|
||||||
(String) SIGN_DATA[4],
|
|
||||||
(String) SIGN_DATA[5],
|
|
||||||
(String) SIGN_DATA[6],
|
|
||||||
(String) SIGN_DATA[7],
|
|
||||||
(String) SIGN_DATA[8],
|
|
||||||
(String) SIGN_DATA[9],
|
|
||||||
(String) SIGN_DATA[10],
|
|
||||||
(String) SIGN_DATA[11],
|
|
||||||
forceData);
|
|
||||||
signs.remove(id);
|
signs.remove(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,12 +10,13 @@ import org.bukkit.block.BlockState;
|
|||||||
class SignUpdateProcess {
|
class SignUpdateProcess {
|
||||||
|
|
||||||
static void process(Statement statement, Object object, String user, int action, int time) {
|
static void process(Statement statement, Object object, String user, int action, int time) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're switching blocks around quickly.
|
* We're switching blocks around quickly. This block could already be removed
|
||||||
* This block could already be removed again by the time the server tries to modify it.
|
* again by the time the server tries to modify it. Ignore any errors.
|
||||||
* Ignore any errors.
|
|
||||||
*/
|
*/
|
||||||
if (object instanceof BlockState) {
|
if (object instanceof BlockState) {
|
||||||
|
|
||||||
BlockState block = (BlockState) object;
|
BlockState block = (BlockState) object;
|
||||||
int x = block.getX();
|
int x = block.getX();
|
||||||
int y = block.getY();
|
int y = block.getY();
|
||||||
@@ -24,20 +25,26 @@ class SignUpdateProcess {
|
|||||||
int userid = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
int userid = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||||
String query = "";
|
String query = "";
|
||||||
if (action == 0) {
|
if (action == 0) {
|
||||||
query =
|
|
||||||
"SELECT color, color_secondary, data, waxed, face, line_1, line_2, line_3, line_4, line_5, line_6, line_7, line_8 FROM "
|
query = "SELECT color, color_secondary, data, waxed, face, line_1, line_2, line_3, line_4, line_5, line_6, line_7, line_8 FROM "
|
||||||
+ ConfigHandler.prefix + "sign WHERE user='" + userid + "' AND wid='" + wid
|
+ ConfigHandler.prefix + "sign WHERE user='" + userid + "' AND wid='" + wid + "' AND x='" + x
|
||||||
+ "' AND x='" + x + "' AND z='" + z + "' AND y='" + y + "' AND time < '" + time
|
+ "' AND z='" + z + "' AND y='" + y + "' AND time < '" + time
|
||||||
+ "' ORDER BY rowid DESC LIMIT 0, 1";
|
+ "' ORDER BY rowid DESC LIMIT 0, 1";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
query =
|
|
||||||
"SELECT color, color_secondary, data, waxed, face, line_1, line_2, line_3, line_4, line_5, line_6, line_7, line_8 FROM "
|
query = "SELECT color, color_secondary, data, waxed, face, line_1, line_2, line_3, line_4, line_5, line_6, line_7, line_8 FROM "
|
||||||
+ ConfigHandler.prefix + "sign WHERE user='" + userid + "' AND wid='" + wid
|
+ ConfigHandler.prefix + "sign WHERE user='" + userid + "' AND wid='" + wid + "' AND x='" + x
|
||||||
+ "' AND x='" + x + "' AND z='" + z + "' AND y='" + y + "' AND time >= '" + time
|
+ "' AND z='" + z + "' AND y='" + y + "' AND time >= '" + time
|
||||||
+ "' ORDER BY rowid ASC LIMIT 0, 1";
|
+ "' ORDER BY rowid ASC LIMIT 0, 1";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SignStatement.getData(statement, block, query);
|
SignStatement.getData(statement, block, query);
|
||||||
Util.updateBlock(block);
|
Util.updateBlock(block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,17 +9,21 @@ import org.bukkit.block.BlockState;
|
|||||||
class SkullUpdateProcess {
|
class SkullUpdateProcess {
|
||||||
|
|
||||||
static void process(Statement statement, Object object, int rowId) {
|
static void process(Statement statement, Object object, int rowId) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're switching blocks around quickly.
|
* We're switching blocks around quickly. This block could already be removed
|
||||||
* This block could already be removed again by the time the server tries to modify it.
|
* again by the time the server tries to modify it. Ignore any errors.
|
||||||
* Ignore any errors.
|
|
||||||
*/
|
*/
|
||||||
if (object instanceof BlockState) {
|
if (object instanceof BlockState) {
|
||||||
|
|
||||||
BlockState block = (BlockState) object;
|
BlockState block = (BlockState) object;
|
||||||
String query =
|
String query = "SELECT owner, skin FROM " + ConfigHandler.prefix + "skull WHERE rowid='" + rowId
|
||||||
"SELECT owner, skin FROM " + ConfigHandler.prefix + "skull WHERE rowid='" + rowId + "' LIMIT 0, 1";
|
+ "' LIMIT 0, 1";
|
||||||
SkullStatement.getData(statement, block, query);
|
SkullStatement.getData(statement, block, query);
|
||||||
Util.updateBlock(block);
|
Util.updateBlock(block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,48 +13,56 @@ import org.bukkit.block.BlockState;
|
|||||||
|
|
||||||
class StructureGrowthProcess {
|
class StructureGrowthProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(Statement statement, PreparedStatement preparedStmt, int batchCount, int processId, int id,
|
||||||
Statement statement,
|
String user, Object object, int replaceBlockCount)
|
||||||
PreparedStatement preparedStmt,
|
{
|
||||||
int batchCount,
|
|
||||||
int processId,
|
|
||||||
int id,
|
|
||||||
String user,
|
|
||||||
Object object,
|
|
||||||
int replaceBlockCount) {
|
|
||||||
if (object instanceof BlockState) {
|
if (object instanceof BlockState) {
|
||||||
|
|
||||||
BlockState block = (BlockState) object;
|
BlockState block = (BlockState) object;
|
||||||
Map<Integer, List<BlockState>> blockLists = Consumer.consumerBlockList.get(processId);
|
Map<Integer, List<BlockState>> blockLists = Consumer.consumerBlockList.get(processId);
|
||||||
if (blockLists.get(id) != null) {
|
if (blockLists.get(id) != null) {
|
||||||
|
|
||||||
List<BlockState> blockStates = blockLists.get(id);
|
List<BlockState> blockStates = blockLists.get(id);
|
||||||
String resultData = Lookup.whoPlacedCache(block);
|
String resultData = Lookup.whoPlacedCache(block);
|
||||||
if (resultData.isEmpty()) {
|
if (resultData.isEmpty()) {
|
||||||
|
|
||||||
resultData = Lookup.whoPlaced(statement, block);
|
resultData = Lookup.whoPlaced(statement, block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultData.length() > 0) {
|
if (resultData.length() > 0) {
|
||||||
|
|
||||||
user = resultData;
|
user = resultData;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (BlockState blockState : blockStates) {
|
for (BlockState blockState : blockStates) {
|
||||||
|
|
||||||
if (count < replaceBlockCount) {
|
if (count < replaceBlockCount) {
|
||||||
BlockBreakLogger.log(
|
|
||||||
preparedStmt,
|
BlockBreakLogger.log(preparedStmt, batchCount, user, blockState.getLocation(),
|
||||||
batchCount,
|
Util.getBlockId(blockState.getType()), 0, null, blockState.getBlockData().getAsString(),
|
||||||
user,
|
|
||||||
blockState.getLocation(),
|
|
||||||
Util.getBlockId(blockState.getType()),
|
|
||||||
0,
|
|
||||||
null,
|
|
||||||
blockState.getBlockData().getAsString(),
|
|
||||||
null);
|
null);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
BlockPlaceLogger.log(
|
|
||||||
preparedStmt, batchCount, user, blockState, 0, 0, null, -1, false, null, null, null);
|
BlockPlaceLogger.log(preparedStmt, batchCount, user, blockState, 0, 0, null, -1, false, null,
|
||||||
|
null, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blockLists.remove(id);
|
blockLists.remove(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,25 +11,38 @@ import net.coreprotect.utility.Chat;
|
|||||||
|
|
||||||
class WorldInsertProcess {
|
class WorldInsertProcess {
|
||||||
|
|
||||||
static void process(
|
static void process(PreparedStatement preparedStmt, int batchCount, Statement statement, Object world,
|
||||||
PreparedStatement preparedStmt, int batchCount, Statement statement, Object world, int worldId) {
|
int worldId)
|
||||||
|
{
|
||||||
|
|
||||||
if (world instanceof String) {
|
if (world instanceof String) {
|
||||||
|
|
||||||
String query = "SELECT id FROM " + ConfigHandler.prefix + "world WHERE id = '" + worldId + "' LIMIT 0, 1";
|
String query = "SELECT id FROM " + ConfigHandler.prefix + "world WHERE id = '" + worldId + "' LIMIT 0, 1";
|
||||||
boolean hasMaterial = MaterialStatement.hasMaterial(statement, query);
|
boolean hasMaterial = MaterialStatement.hasMaterial(statement, query);
|
||||||
if (!hasMaterial) {
|
if (!hasMaterial) {
|
||||||
|
|
||||||
WorldStatement.insert(preparedStmt, batchCount, worldId, (String) world);
|
WorldStatement.insert(preparedStmt, batchCount, worldId, (String) world);
|
||||||
|
|
||||||
// validate ID maps to ensure mapping wasn't reloaded from database prior to this insertion completing
|
// validate ID maps to ensure mapping wasn't reloaded from database prior to
|
||||||
|
// this insertion completing
|
||||||
ConfigHandler.worlds.put((String) world, worldId);
|
ConfigHandler.worlds.put((String) world, worldId);
|
||||||
ConfigHandler.worldsReversed.put(worldId, (String) world);
|
ConfigHandler.worldsReversed.put(worldId, (String) world);
|
||||||
if (worldId > ConfigHandler.worldId) {
|
if (worldId > ConfigHandler.worldId) {
|
||||||
|
|
||||||
ConfigHandler.worldId = worldId;
|
ConfigHandler.worldId = worldId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.CACHE_ERROR, "world"));
|
Chat.console(Phrase.build(Phrase.CACHE_ERROR, "world"));
|
||||||
Chat.console(Phrase.build(Phrase.CACHE_RELOAD, Selector.SECOND));
|
Chat.console(Phrase.build(Phrase.CACHE_RELOAD, Selector.SECOND));
|
||||||
ConfigHandler.loadWorlds(statement);
|
ConfigHandler.loadWorlds(statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -29,183 +29,202 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class ContainerRollback extends Rollback {
|
public class ContainerRollback extends Rollback {
|
||||||
|
|
||||||
public static void performContainerRollbackRestore(
|
public static void performContainerRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids,
|
||||||
Statement statement,
|
List<String> checkUsers, String timeString, List<Object> restrictList, Map<Object, Boolean> excludeList,
|
||||||
CommandSender user,
|
List<String> excludeUserList, List<Integer> actionList, final Location location, Integer[] radius,
|
||||||
List<String> checkUuids,
|
long startTime, long endTime, boolean restrictWorld, boolean lookup, boolean verbose,
|
||||||
List<String> checkUsers,
|
final int rollbackType)
|
||||||
String timeString,
|
{
|
||||||
List<Object> restrictList,
|
|
||||||
Map<Object, Boolean> excludeList,
|
|
||||||
List<String> excludeUserList,
|
|
||||||
List<Integer> actionList,
|
|
||||||
final Location location,
|
|
||||||
Integer[] radius,
|
|
||||||
long startTime,
|
|
||||||
long endTime,
|
|
||||||
boolean restrictWorld,
|
|
||||||
boolean lookup,
|
|
||||||
boolean verbose,
|
|
||||||
final int rollbackType) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
long timeStart = System.currentTimeMillis();
|
long timeStart = System.currentTimeMillis();
|
||||||
|
|
||||||
final List<Object[]> lookupList = Lookup.performLookupRaw(
|
final List<Object[]> lookupList = Lookup.performLookupRaw(statement, user, checkUuids, checkUsers,
|
||||||
statement,
|
restrictList, excludeList, excludeUserList, actionList, location, radius, null, startTime, endTime,
|
||||||
user,
|
-1, -1, restrictWorld, lookup);
|
||||||
checkUuids,
|
|
||||||
checkUsers,
|
|
||||||
restrictList,
|
|
||||||
excludeList,
|
|
||||||
excludeUserList,
|
|
||||||
actionList,
|
|
||||||
location,
|
|
||||||
radius,
|
|
||||||
null,
|
|
||||||
startTime,
|
|
||||||
endTime,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
restrictWorld,
|
|
||||||
lookup);
|
|
||||||
if (rollbackType == 1) {
|
if (rollbackType == 1) {
|
||||||
|
|
||||||
Collections.reverse(lookupList);
|
Collections.reverse(lookupList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String userString = "#server";
|
String userString = "#server";
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
|
||||||
userString = user.getName();
|
userString = user.getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Queue.queueRollbackUpdate(
|
Queue.queueRollbackUpdate(userString, location, lookupList, Process.CONTAINER_ROLLBACK_UPDATE,
|
||||||
userString,
|
|
||||||
location,
|
|
||||||
lookupList,
|
|
||||||
Process.CONTAINER_ROLLBACK_UPDATE,
|
|
||||||
rollbackType); // Perform update transaction in consumer
|
rollbackType); // Perform update transaction in consumer
|
||||||
|
|
||||||
final String finalUserString = userString;
|
final String finalUserString = userString;
|
||||||
ConfigHandler.rollbackHash.put(userString, new int[] {0, 0, 0, 0, 0});
|
ConfigHandler.rollbackHash.put(userString, new int[] { 0, 0, 0, 0, 0 });
|
||||||
|
|
||||||
Scheduler.scheduleSyncDelayedTask(
|
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), new Runnable() {
|
||||||
CoreProtect.getInstance(),
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
int[] rollbackHashData = ConfigHandler.rollbackHash.get(finalUserString);
|
|
||||||
int itemCount = rollbackHashData[0];
|
|
||||||
// int blockCount = rollbackHashData[1];
|
|
||||||
int entityCount = rollbackHashData[2];
|
|
||||||
Block block = location.getBlock();
|
|
||||||
|
|
||||||
if (!block.getWorld().isChunkLoaded(block.getChunk())) {
|
@Override
|
||||||
block.getWorld().getChunkAt(block.getLocation());
|
public void run() {
|
||||||
}
|
|
||||||
Object container = null;
|
|
||||||
Material type = block.getType();
|
|
||||||
List<ItemFrame> matchingFrames = new ArrayList<>();
|
|
||||||
|
|
||||||
if (BlockGroup.CONTAINERS.contains(type)) {
|
try {
|
||||||
container = Util.getContainerInventory(block.getState(), false);
|
|
||||||
} else {
|
|
||||||
for (Entity entity : block.getChunk().getEntities()) {
|
|
||||||
if (entity.getLocation().getBlockX() == location.getBlockX()
|
|
||||||
&& entity.getLocation().getBlockY() == location.getBlockY()
|
|
||||||
&& entity.getLocation().getBlockZ() == location.getBlockZ()) {
|
|
||||||
if (entity instanceof ArmorStand) {
|
|
||||||
type = Material.ARMOR_STAND;
|
|
||||||
container = Util.getEntityEquipment((LivingEntity) entity);
|
|
||||||
} else if (entity instanceof ItemFrame) {
|
|
||||||
type = Material.ITEM_FRAME;
|
|
||||||
container = entity;
|
|
||||||
matchingFrames.add((ItemFrame) entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int modifyCount = 0;
|
int[] rollbackHashData = ConfigHandler.rollbackHash.get(finalUserString);
|
||||||
if (container != null) {
|
int itemCount = rollbackHashData[0];
|
||||||
for (Object[] lookupRow : lookupList) {
|
// int blockCount = rollbackHashData[1];
|
||||||
// int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
int entityCount = rollbackHashData[2];
|
||||||
// int rowId = lookupRow[0];
|
Block block = location.getBlock();
|
||||||
// int rowTime = (Integer)lookupRow[1];
|
|
||||||
// int rowUserId = (Integer)lookupRow[2];
|
|
||||||
// int rowX = (Integer)lookupRow[3];
|
|
||||||
// int rowY = (Integer)lookupRow[4];
|
|
||||||
// int rowZ = (Integer)lookupRow[5];
|
|
||||||
int rowTypeRaw = (Integer) lookupRow[6];
|
|
||||||
int rowData = (Integer) lookupRow[7];
|
|
||||||
int rowAction = (Integer) lookupRow[8];
|
|
||||||
int rowRolledBack = Util.rolledBack((Integer) lookupRow[9], false);
|
|
||||||
// int rowWid = (Integer)lookupRow[10];
|
|
||||||
int rowAmount = (Integer) lookupRow[11];
|
|
||||||
byte[] rowMetadata = (byte[]) lookupRow[12];
|
|
||||||
Material rowType = Util.getType(rowTypeRaw);
|
|
||||||
|
|
||||||
if ((rollbackType == 0 && rowRolledBack == 0)
|
if (!block.getWorld().isChunkLoaded(block.getChunk())) {
|
||||||
|| (rollbackType == 1 && rowRolledBack == 1)) {
|
|
||||||
modifyCount = modifyCount + rowAmount;
|
|
||||||
int action = 0;
|
|
||||||
|
|
||||||
if (rollbackType == 0 && rowAction == 0) {
|
block.getWorld().getChunkAt(block.getLocation());
|
||||||
action = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rollbackType == 1 && rowAction == 1) {
|
|
||||||
action = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack itemstack = new ItemStack(rowType, rowAmount);
|
|
||||||
Object[] populatedStack =
|
|
||||||
Rollback.populateItemStack(itemstack, rowMetadata);
|
|
||||||
int slot = (Integer) populatedStack[0];
|
|
||||||
String faceData = (String) populatedStack[1];
|
|
||||||
itemstack = (ItemStack) populatedStack[2];
|
|
||||||
|
|
||||||
if (type == Material.ITEM_FRAME && faceData.length() > 0) {
|
|
||||||
BlockFace blockFace = BlockFace.valueOf(faceData);
|
|
||||||
ItemFrame itemFrame = (ItemFrame) container;
|
|
||||||
if (blockFace != itemFrame.getFacing()) {
|
|
||||||
for (ItemFrame frame : matchingFrames) {
|
|
||||||
if (blockFace == frame.getFacing()) {
|
|
||||||
container = frame;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rollback.modifyContainerItems(type, container, slot, itemstack, action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
matchingFrames.clear();
|
|
||||||
|
|
||||||
ConfigHandler.rollbackHash.put(
|
|
||||||
finalUserString, new int[] {itemCount, modifyCount, entityCount, 1, 1});
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
location,
|
Object container = null;
|
||||||
0);
|
Material type = block.getType();
|
||||||
|
List<ItemFrame> matchingFrames = new ArrayList<>();
|
||||||
|
|
||||||
|
if (BlockGroup.CONTAINERS.contains(type)) {
|
||||||
|
|
||||||
|
container = Util.getContainerInventory(block.getState(), false);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
for (Entity entity : block.getChunk().getEntities()) {
|
||||||
|
|
||||||
|
if (entity.getLocation().getBlockX() == location.getBlockX()
|
||||||
|
&& entity.getLocation().getBlockY() == location.getBlockY()
|
||||||
|
&& entity.getLocation().getBlockZ() == location.getBlockZ())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (entity instanceof ArmorStand) {
|
||||||
|
|
||||||
|
type = Material.ARMOR_STAND;
|
||||||
|
container = Util.getEntityEquipment((LivingEntity) entity);
|
||||||
|
|
||||||
|
} else if (entity instanceof ItemFrame) {
|
||||||
|
|
||||||
|
type = Material.ITEM_FRAME;
|
||||||
|
container = entity;
|
||||||
|
matchingFrames.add((ItemFrame) entity);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int modifyCount = 0;
|
||||||
|
if (container != null) {
|
||||||
|
|
||||||
|
for (Object[] lookupRow : lookupList) {
|
||||||
|
|
||||||
|
// int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||||
|
// int rowId = lookupRow[0];
|
||||||
|
// int rowTime = (Integer)lookupRow[1];
|
||||||
|
// int rowUserId = (Integer)lookupRow[2];
|
||||||
|
// int rowX = (Integer)lookupRow[3];
|
||||||
|
// int rowY = (Integer)lookupRow[4];
|
||||||
|
// int rowZ = (Integer)lookupRow[5];
|
||||||
|
int rowTypeRaw = (Integer) lookupRow[6];
|
||||||
|
int rowData = (Integer) lookupRow[7];
|
||||||
|
int rowAction = (Integer) lookupRow[8];
|
||||||
|
int rowRolledBack = Util.rolledBack((Integer) lookupRow[9], false);
|
||||||
|
// int rowWid = (Integer)lookupRow[10];
|
||||||
|
int rowAmount = (Integer) lookupRow[11];
|
||||||
|
byte[] rowMetadata = (byte[]) lookupRow[12];
|
||||||
|
Material rowType = Util.getType(rowTypeRaw);
|
||||||
|
|
||||||
|
if ((rollbackType == 0 && rowRolledBack == 0)
|
||||||
|
|| (rollbackType == 1 && rowRolledBack == 1))
|
||||||
|
{
|
||||||
|
|
||||||
|
modifyCount = modifyCount + rowAmount;
|
||||||
|
int action = 0;
|
||||||
|
|
||||||
|
if (rollbackType == 0 && rowAction == 0) {
|
||||||
|
|
||||||
|
action = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rollbackType == 1 && rowAction == 1) {
|
||||||
|
|
||||||
|
action = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack itemstack = new ItemStack(rowType, rowAmount);
|
||||||
|
Object[] populatedStack = Rollback.populateItemStack(itemstack, rowMetadata);
|
||||||
|
int slot = (Integer) populatedStack[0];
|
||||||
|
String faceData = (String) populatedStack[1];
|
||||||
|
itemstack = (ItemStack) populatedStack[2];
|
||||||
|
|
||||||
|
if (type == Material.ITEM_FRAME && faceData.length() > 0) {
|
||||||
|
|
||||||
|
BlockFace blockFace = BlockFace.valueOf(faceData);
|
||||||
|
ItemFrame itemFrame = (ItemFrame) container;
|
||||||
|
if (blockFace != itemFrame.getFacing()) {
|
||||||
|
|
||||||
|
for (ItemFrame frame : matchingFrames) {
|
||||||
|
|
||||||
|
if (blockFace == frame.getFacing()) {
|
||||||
|
|
||||||
|
container = frame;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Rollback.modifyContainerItems(type, container, slot, itemstack, action);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
matchingFrames.clear();
|
||||||
|
|
||||||
|
ConfigHandler.rollbackHash.put(finalUserString,
|
||||||
|
new int[]
|
||||||
|
{ itemCount, modifyCount, entityCount, 1, 1 });
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, location, 0);
|
||||||
|
|
||||||
int[] rollbackHashData = ConfigHandler.rollbackHash.get(finalUserString);
|
int[] rollbackHashData = ConfigHandler.rollbackHash.get(finalUserString);
|
||||||
int next = rollbackHashData[3];
|
int next = rollbackHashData[3];
|
||||||
int sleepTime = 0;
|
int sleepTime = 0;
|
||||||
|
|
||||||
while (next == 0) {
|
while (next == 0) {
|
||||||
|
|
||||||
sleepTime = sleepTime + 5;
|
sleepTime = sleepTime + 5;
|
||||||
Thread.sleep(5);
|
Thread.sleep(5);
|
||||||
rollbackHashData = ConfigHandler.rollbackHash.get(finalUserString);
|
rollbackHashData = ConfigHandler.rollbackHash.get(finalUserString);
|
||||||
next = rollbackHashData[3];
|
next = rollbackHashData[3];
|
||||||
if (sleepTime > 300000) {
|
if (sleepTime > 300000) {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.ROLLBACK_ABORTED));
|
Chat.console(Phrase.build(Phrase.ROLLBACK_ABORTED));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rollbackHashData = ConfigHandler.rollbackHash.get(finalUserString);
|
rollbackHashData = ConfigHandler.rollbackHash.get(finalUserString);
|
||||||
@@ -214,35 +233,29 @@ public class ContainerRollback extends Rollback {
|
|||||||
double totalSeconds = (timeFinish - timeStart) / 1000.0;
|
double totalSeconds = (timeFinish - timeStart) / 1000.0;
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
|
||||||
int file = -1;
|
int file = -1;
|
||||||
if (blockCount > 0) {
|
if (blockCount > 0) {
|
||||||
|
|
||||||
file = 1;
|
file = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int itemCount = 0;
|
int itemCount = 0;
|
||||||
int entityCount = 0;
|
int entityCount = 0;
|
||||||
|
|
||||||
RollbackComplete.output(
|
RollbackComplete.output(user, location, checkUsers, restrictList, excludeList, excludeUserList,
|
||||||
user,
|
actionList, timeString, file, totalSeconds, itemCount, blockCount, entityCount, rollbackType,
|
||||||
location,
|
radius, verbose, restrictWorld, 0);
|
||||||
checkUsers,
|
|
||||||
restrictList,
|
|
||||||
excludeList,
|
|
||||||
excludeUserList,
|
|
||||||
actionList,
|
|
||||||
timeString,
|
|
||||||
file,
|
|
||||||
totalSeconds,
|
|
||||||
itemCount,
|
|
||||||
blockCount,
|
|
||||||
entityCount,
|
|
||||||
rollbackType,
|
|
||||||
radius,
|
|
||||||
verbose,
|
|
||||||
restrictWorld,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -42,175 +42,279 @@ public class Database extends Queue {
|
|||||||
public static final int ITEM = 13;
|
public static final int ITEM = 13;
|
||||||
|
|
||||||
public static void beginTransaction(Statement statement, boolean isMySQL) {
|
public static void beginTransaction(Statement statement, boolean isMySQL) {
|
||||||
|
|
||||||
Consumer.transacting = true;
|
Consumer.transacting = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (isMySQL) {
|
if (isMySQL) {
|
||||||
|
|
||||||
statement.executeUpdate("START TRANSACTION");
|
statement.executeUpdate("START TRANSACTION");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
statement.executeUpdate("BEGIN TRANSACTION");
|
statement.executeUpdate("BEGIN TRANSACTION");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void commitTransaction(Statement statement, boolean isMySQL) throws Exception {
|
public static void commitTransaction(Statement statement, boolean isMySQL) throws Exception {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (isMySQL) {
|
if (isMySQL) {
|
||||||
|
|
||||||
statement.executeUpdate("COMMIT");
|
statement.executeUpdate("COMMIT");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
statement.executeUpdate("COMMIT TRANSACTION");
|
statement.executeUpdate("COMMIT TRANSACTION");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
if (e.getMessage().startsWith("[SQLITE_BUSY]") && count < 30) {
|
if (e.getMessage().startsWith("[SQLITE_BUSY]") && count < 30) {
|
||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Consumer.transacting = false;
|
Consumer.transacting = false;
|
||||||
Consumer.interrupt = false;
|
Consumer.interrupt = false;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void performCheckpoint(Statement statement, boolean isMySQL) throws SQLException {
|
public static void performCheckpoint(Statement statement, boolean isMySQL) throws SQLException {
|
||||||
|
|
||||||
if (!isMySQL) {
|
if (!isMySQL) {
|
||||||
|
|
||||||
statement.executeUpdate("PRAGMA wal_checkpoint(TRUNCATE)");
|
statement.executeUpdate("PRAGMA wal_checkpoint(TRUNCATE)");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMultiInt(PreparedStatement statement, int value, int count) {
|
public static void setMultiInt(PreparedStatement statement, int value, int count) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
for (int i = 1; i <= count; i++) {
|
for (int i = 1; i <= count; i++) {
|
||||||
|
|
||||||
statement.setInt(i, value);
|
statement.setInt(i, value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasReturningKeys() {
|
public static boolean hasReturningKeys() {
|
||||||
|
|
||||||
return (!Config.getGlobal().MYSQL && ConfigHandler.SERVER_VERSION >= 20);
|
return (!Config.getGlobal().MYSQL && ConfigHandler.SERVER_VERSION >= 20);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void containerBreakCheck(
|
public static void containerBreakCheck(String user, Material type, Object container, ItemStack[] contents,
|
||||||
String user, Material type, Object container, ItemStack[] contents, Location location) {
|
Location location)
|
||||||
|
{
|
||||||
|
|
||||||
if (BlockGroup.CONTAINERS.contains(type) && !BlockGroup.SHULKER_BOXES.contains(type)) {
|
if (BlockGroup.CONTAINERS.contains(type) && !BlockGroup.SHULKER_BOXES.contains(type)) {
|
||||||
|
|
||||||
if (Config.getConfig(location.getWorld()).ITEM_TRANSACTIONS) {
|
if (Config.getConfig(location.getWorld()).ITEM_TRANSACTIONS) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (contents == null) {
|
if (contents == null) {
|
||||||
|
|
||||||
contents = Util.getContainerContents(type, container, location);
|
contents = Util.getContainerContents(type, container, location);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contents != null) {
|
if (contents != null) {
|
||||||
|
|
||||||
List<ItemStack[]> forceList = new ArrayList<>();
|
List<ItemStack[]> forceList = new ArrayList<>();
|
||||||
forceList.add(Util.getContainerState(contents));
|
forceList.add(Util.getContainerState(contents));
|
||||||
ConfigHandler.forceContainer.put(
|
ConfigHandler.forceContainer.put(user.toLowerCase(Locale.ROOT) + "." + location.getBlockX()
|
||||||
user.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "." + location.getBlockY()
|
+ "." + location.getBlockY() + "." + location.getBlockZ(), forceList);
|
||||||
+ "." + location.getBlockZ(),
|
|
||||||
forceList);
|
|
||||||
Queue.queueContainerBreak(user, location, type, contents);
|
Queue.queueContainerBreak(user, location, type, contents);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Connection getConnection(boolean onlyCheckTransacting) {
|
public static Connection getConnection(boolean onlyCheckTransacting) {
|
||||||
|
|
||||||
// Previously 250ms; long consumer commit time may be due to batching
|
// Previously 250ms; long consumer commit time may be due to batching
|
||||||
// TODO: Investigate, potentially remove batching for SQLite connections
|
// TODO: Investigate, potentially remove batching for SQLite connections
|
||||||
return getConnection(false, false, onlyCheckTransacting, 1000);
|
return getConnection(false, false, onlyCheckTransacting, 1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Connection getConnection(boolean force, int waitTime) {
|
public static Connection getConnection(boolean force, int waitTime) {
|
||||||
|
|
||||||
return getConnection(force, false, false, waitTime);
|
return getConnection(force, false, false, waitTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Connection getConnection(boolean force, boolean startup, boolean onlyCheckTransacting, int waitTime) {
|
public static Connection getConnection(boolean force, boolean startup, boolean onlyCheckTransacting, int waitTime) {
|
||||||
|
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!force && (ConfigHandler.converterRunning || ConfigHandler.purgeRunning)) {
|
if (!force && (ConfigHandler.converterRunning || ConfigHandler.purgeRunning)) {
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getGlobal().MYSQL) {
|
if (Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
connection = ConfigHandler.hikariDataSource.getConnection();
|
connection = ConfigHandler.hikariDataSource.getConnection();
|
||||||
ConfigHandler.databaseReachable = true;
|
ConfigHandler.databaseReachable = true;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
ConfigHandler.databaseReachable = false;
|
ConfigHandler.databaseReachable = false;
|
||||||
Chat.sendConsoleMessage(Color.RED + "[CoreProtect] " + Phrase.build(Phrase.MYSQL_UNAVAILABLE));
|
Chat.sendConsoleMessage(Color.RED + "[CoreProtect] " + Phrase.build(Phrase.MYSQL_UNAVAILABLE));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (Consumer.transacting && onlyCheckTransacting) {
|
if (Consumer.transacting && onlyCheckTransacting) {
|
||||||
|
|
||||||
Consumer.interrupt = true;
|
Consumer.interrupt = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
while (Consumer.isPaused && !force && (Consumer.transacting || !onlyCheckTransacting)) {
|
while (Consumer.isPaused && !force && (Consumer.transacting || !onlyCheckTransacting)) {
|
||||||
|
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
long pauseTime = (System.nanoTime() - startTime) / 1000000;
|
long pauseTime = (System.nanoTime() - startTime) / 1000000;
|
||||||
|
|
||||||
if (pauseTime >= waitTime) {
|
if (pauseTime >= waitTime) {
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String database = "jdbc:sqlite:" + ConfigHandler.path + ConfigHandler.sqlite + "";
|
String database = "jdbc:sqlite:" + ConfigHandler.path + ConfigHandler.sqlite + "";
|
||||||
connection = DriverManager.getConnection(database);
|
connection = DriverManager.getConnection(database);
|
||||||
|
|
||||||
ConfigHandler.databaseReachable = true;
|
ConfigHandler.databaseReachable = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void closeConnection() {
|
public static void closeConnection() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.hikariDataSource != null) {
|
if (ConfigHandler.hikariDataSource != null) {
|
||||||
|
|
||||||
ConfigHandler.hikariDataSource.close();
|
ConfigHandler.hikariDataSource.close();
|
||||||
ConfigHandler.hikariDataSource = null;
|
ConfigHandler.hikariDataSource = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void performUpdate(Statement statement, long id, int rb, int table) {
|
public static void performUpdate(Statement statement, long id, int rb, int table) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int rolledBack = Util.toggleRolledBack(
|
|
||||||
rb, (table == 2 || table == 3 || table == 4)); // co_item, co_container, co_block
|
int rolledBack = Util.toggleRolledBack(rb, (table == 2 || table == 3 || table == 4)); // co_item,
|
||||||
|
// co_container,
|
||||||
|
// co_block
|
||||||
if (table == 1 || table == 3) {
|
if (table == 1 || table == 3) {
|
||||||
|
|
||||||
statement.executeUpdate("UPDATE " + ConfigHandler.prefix + "container SET rolled_back='" + rolledBack
|
statement.executeUpdate("UPDATE " + ConfigHandler.prefix + "container SET rolled_back='" + rolledBack
|
||||||
+ "' WHERE rowid='" + id + "'");
|
+ "' WHERE rowid='" + id + "'");
|
||||||
|
|
||||||
} else if (table == 2) {
|
} else if (table == 2) {
|
||||||
|
|
||||||
statement.executeUpdate("UPDATE " + ConfigHandler.prefix + "item SET rolled_back='" + rolledBack
|
statement.executeUpdate("UPDATE " + ConfigHandler.prefix + "item SET rolled_back='" + rolledBack
|
||||||
+ "' WHERE rowid='" + id + "'");
|
+ "' WHERE rowid='" + id + "'");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
statement.executeUpdate("UPDATE " + ConfigHandler.prefix + "block SET rolled_back='" + rolledBack
|
statement.executeUpdate("UPDATE " + ConfigHandler.prefix + "block SET rolled_back='" + rolledBack
|
||||||
+ "' WHERE rowid='" + id + "'");
|
+ "' WHERE rowid='" + id + "'");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PreparedStatement prepareStatement(Connection connection, int type, boolean keys) {
|
public static PreparedStatement prepareStatement(Connection connection, int type, boolean keys) {
|
||||||
|
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String signInsert = "INSERT INTO " + ConfigHandler.prefix
|
String signInsert = "INSERT INTO " + ConfigHandler.prefix
|
||||||
+ "sign (time, user, wid, x, y, z, action, color, color_secondary, data, waxed, face, line_1, line_2, line_3, line_4, line_5, line_6, line_7, line_8) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
+ "sign (time, user, wid, x, y, z, action, color, color_secondary, data, waxed, face, line_1, line_2, line_3, line_4, line_5, line_6, line_7, line_8) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
String blockInsert = "INSERT INTO " + ConfigHandler.prefix
|
String blockInsert = "INSERT INTO " + ConfigHandler.prefix
|
||||||
@@ -234,6 +338,7 @@ public class Database extends Queue {
|
|||||||
String blockdataInsert = "INSERT INTO " + ConfigHandler.prefix + "blockdata_map (id, data) VALUES (?, ?)";
|
String blockdataInsert = "INSERT INTO " + ConfigHandler.prefix + "blockdata_map (id, data) VALUES (?, ?)";
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
||||||
case SIGN:
|
case SIGN:
|
||||||
preparedStatement = prepareStatement(connection, signInsert, keys);
|
preparedStatement = prepareStatement(connection, signInsert, keys);
|
||||||
break;
|
break;
|
||||||
@@ -276,89 +381,114 @@ public class Database extends Queue {
|
|||||||
case BLOCKDATA:
|
case BLOCKDATA:
|
||||||
preparedStatement = prepareStatement(connection, blockdataInsert, keys);
|
preparedStatement = prepareStatement(connection, blockdataInsert, keys);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return preparedStatement;
|
return preparedStatement;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PreparedStatement prepareStatement(Connection connection, String query, boolean keys) {
|
private static PreparedStatement prepareStatement(Connection connection, String query, boolean keys) {
|
||||||
|
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (keys) {
|
if (keys) {
|
||||||
|
|
||||||
if (hasReturningKeys()) {
|
if (hasReturningKeys()) {
|
||||||
|
|
||||||
preparedStatement = connection.prepareStatement(query + " RETURNING rowid");
|
preparedStatement = connection.prepareStatement(query + " RETURNING rowid");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
preparedStatement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
|
preparedStatement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
preparedStatement = connection.prepareStatement(query);
|
preparedStatement = connection.prepareStatement(query);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return preparedStatement;
|
return preparedStatement;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeTables(String prefix, Statement statement) {
|
private static void initializeTables(String prefix, Statement statement) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
if (!Config.getGlobal().DISABLE_WAL) {
|
if (!Config.getGlobal().DISABLE_WAL) {
|
||||||
|
|
||||||
statement.executeUpdate("PRAGMA journal_mode=WAL;");
|
statement.executeUpdate("PRAGMA journal_mode=WAL;");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
statement.executeUpdate("PRAGMA journal_mode=DELETE;");
|
statement.executeUpdate("PRAGMA journal_mode=DELETE;");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean lockInitialized = false;
|
boolean lockInitialized = false;
|
||||||
String query = "SELECT rowid as id FROM " + prefix + "database_lock WHERE rowid='1' LIMIT 1";
|
String query = "SELECT rowid as id FROM " + prefix + "database_lock WHERE rowid='1' LIMIT 1";
|
||||||
ResultSet rs = statement.executeQuery(query);
|
ResultSet rs = statement.executeQuery(query);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
lockInitialized = true;
|
lockInitialized = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
if (!lockInitialized) {
|
if (!lockInitialized) {
|
||||||
|
|
||||||
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||||
statement.executeUpdate("INSERT INTO " + prefix
|
statement.executeUpdate("INSERT INTO " + prefix
|
||||||
+ "database_lock (rowid, status, time) VALUES ('1', '0', '" + unixtimestamp + "')");
|
+ "database_lock (rowid, status, time) VALUES ('1', '0', '" + unixtimestamp + "')");
|
||||||
Process.lastLockUpdate = 0;
|
Process.lastLockUpdate = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createDatabaseTables(String prefix, Connection forceConnection, boolean mySQL, boolean purge) {
|
public static void createDatabaseTables(String prefix, Connection forceConnection, boolean mySQL, boolean purge) {
|
||||||
|
|
||||||
ConfigHandler.databaseTables.clear();
|
ConfigHandler.databaseTables.clear();
|
||||||
ConfigHandler.databaseTables.addAll(Arrays.asList(
|
ConfigHandler.databaseTables.addAll(Arrays.asList("art_map", "block", "chat", "command", "container", "item",
|
||||||
"art_map",
|
"database_lock", "entity", "entity_map", "material_map", "blockdata_map", "session", "sign", "skull",
|
||||||
"block",
|
"user", "username_log", "version", "world"));
|
||||||
"chat",
|
|
||||||
"command",
|
|
||||||
"container",
|
|
||||||
"item",
|
|
||||||
"database_lock",
|
|
||||||
"entity",
|
|
||||||
"entity_map",
|
|
||||||
"material_map",
|
|
||||||
"blockdata_map",
|
|
||||||
"session",
|
|
||||||
"sign",
|
|
||||||
"skull",
|
|
||||||
"user",
|
|
||||||
"username_log",
|
|
||||||
"version",
|
|
||||||
"world"));
|
|
||||||
|
|
||||||
if (mySQL) {
|
if (mySQL) {
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try (Connection connection =
|
try (Connection connection = (forceConnection != null ? forceConnection
|
||||||
(forceConnection != null ? forceConnection : Database.getConnection(true, true, true, 0))) {
|
: Database.getConnection(true, true, true, 0)))
|
||||||
|
{
|
||||||
|
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
|
|
||||||
String index = "";
|
String index = "";
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
index = ", INDEX(id)";
|
index = ", INDEX(id)";
|
||||||
@@ -385,12 +515,10 @@ public class Database extends Queue {
|
|||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "item(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data blob, amount int, action tinyint, rolled_back tinyint"
|
+ "item(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data blob, amount int, action tinyint, rolled_back tinyint"
|
||||||
+ index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
+ index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||||
statement.executeUpdate(
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
+ "database_lock(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),status tinyint,time int) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||||
+ "database_lock(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),status tinyint,time int) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
statement.executeUpdate(
|
+ "entity(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, data blob) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
|
||||||
+ "entity(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, data blob) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
|
||||||
index = ", INDEX(id)";
|
index = ", INDEX(id)";
|
||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "entity_map(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,entity varchar(255)"
|
+ "entity_map(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,entity varchar(255)"
|
||||||
@@ -411,9 +539,8 @@ public class Database extends Queue {
|
|||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "sign(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int, z int, action tinyint, color int, color_secondary int, data tinyint, waxed tinyint, face tinyint, line_1 varchar(100), line_2 varchar(100), line_3 varchar(100), line_4 varchar(100), line_5 varchar(100), line_6 varchar(100), line_7 varchar(100), line_8 varchar(100)"
|
+ "sign(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int, z int, action tinyint, color int, color_secondary int, data tinyint, waxed tinyint, face tinyint, line_1 varchar(100), line_2 varchar(100), line_3 varchar(100), line_4 varchar(100), line_5 varchar(100), line_6 varchar(100), line_7 varchar(100), line_8 varchar(100)"
|
||||||
+ index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
+ index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||||
statement.executeUpdate(
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
+ "skull(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, owner varchar(255), skin varchar(255)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||||
+ "skull(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, owner varchar(255), skin varchar(255)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
|
||||||
index = ", INDEX(user), INDEX(uuid)";
|
index = ", INDEX(user), INDEX(uuid)";
|
||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "user(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,user varchar(100),uuid varchar(64)"
|
+ "user(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,user varchar(100),uuid varchar(64)"
|
||||||
@@ -422,266 +549,441 @@ public class Database extends Queue {
|
|||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "username_log(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,uuid varchar(64),user varchar(100)"
|
+ "username_log(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,uuid varchar(64),user varchar(100)"
|
||||||
+ index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
+ index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||||
statement.executeUpdate(
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
+ "version(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,version varchar(16)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||||
+ "version(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,version varchar(16)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
|
||||||
index = ", INDEX(id)";
|
index = ", INDEX(id)";
|
||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "world(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,world varchar(255)"
|
+ "world(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,world varchar(255)"
|
||||||
+ index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
+ index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
|
||||||
if (!purge && forceConnection == null) {
|
if (!purge && forceConnection == null) {
|
||||||
|
|
||||||
initializeTables(prefix, statement);
|
initializeTables(prefix, statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
statement.close();
|
statement.close();
|
||||||
success = true;
|
success = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success && forceConnection == null) {
|
if (!success && forceConnection == null) {
|
||||||
|
|
||||||
Config.getGlobal().MYSQL = false;
|
Config.getGlobal().MYSQL = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mySQL) {
|
if (!mySQL) {
|
||||||
try (Connection connection =
|
|
||||||
(forceConnection != null ? forceConnection : Database.getConnection(true, 0))) {
|
try (Connection connection = (forceConnection != null ? forceConnection
|
||||||
|
: Database.getConnection(true, 0)))
|
||||||
|
{
|
||||||
|
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
List<String> tableData = new ArrayList<>();
|
List<String> tableData = new ArrayList<>();
|
||||||
List<String> indexData = new ArrayList<>();
|
List<String> indexData = new ArrayList<>();
|
||||||
String attachDatabase = "";
|
String attachDatabase = "";
|
||||||
|
|
||||||
if (purge && forceConnection == null) {
|
if (purge && forceConnection == null) {
|
||||||
|
|
||||||
String query = "ATTACH DATABASE '" + ConfigHandler.path + ConfigHandler.sqlite + ".tmp' AS tmp_db";
|
String query = "ATTACH DATABASE '" + ConfigHandler.path + ConfigHandler.sqlite + ".tmp' AS tmp_db";
|
||||||
PreparedStatement preparedStmt = connection.prepareStatement(query);
|
PreparedStatement preparedStmt = connection.prepareStatement(query);
|
||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
attachDatabase = "tmp_db.";
|
attachDatabase = "tmp_db.";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String query =
|
String query = "SELECT type,name FROM " + attachDatabase
|
||||||
"SELECT type,name FROM " + attachDatabase + "sqlite_master WHERE type='table' OR type='index';";
|
+ "sqlite_master WHERE type='table' OR type='index';";
|
||||||
ResultSet rs = statement.executeQuery(query);
|
ResultSet rs = statement.executeQuery(query);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
String type = rs.getString("type");
|
String type = rs.getString("type");
|
||||||
if (type.equalsIgnoreCase("table")) {
|
if (type.equalsIgnoreCase("table")) {
|
||||||
|
|
||||||
tableData.add(rs.getString("name"));
|
tableData.add(rs.getString("name"));
|
||||||
|
|
||||||
} else if (type.equalsIgnoreCase("index")) {
|
} else if (type.equalsIgnoreCase("index")) {
|
||||||
|
|
||||||
indexData.add(rs.getString("name"));
|
indexData.add(rs.getString("name"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "art_map")) {
|
if (!tableData.contains(prefix + "art_map")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "art_map (id INTEGER, art TEXT);");
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "art_map (id INTEGER, art TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "block")) {
|
if (!tableData.contains(prefix + "block")) {
|
||||||
statement.executeUpdate(
|
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "block (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, type INTEGER, data INTEGER, meta BLOB, blockdata BLOB, action INTEGER, rolled_back INTEGER);");
|
+ "block (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, type INTEGER, data INTEGER, meta BLOB, blockdata BLOB, action INTEGER, rolled_back INTEGER);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "chat")) {
|
if (!tableData.contains(prefix + "chat")) {
|
||||||
statement.executeUpdate(
|
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "chat (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, message TEXT);");
|
+ "chat (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, message TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "command")) {
|
if (!tableData.contains(prefix + "command")) {
|
||||||
statement.executeUpdate(
|
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "command (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, message TEXT);");
|
+ "command (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, message TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "container")) {
|
if (!tableData.contains(prefix + "container")) {
|
||||||
statement.executeUpdate(
|
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "container (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, type INTEGER, data INTEGER, amount INTEGER, metadata BLOB, action INTEGER, rolled_back INTEGER);");
|
+ "container (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, type INTEGER, data INTEGER, amount INTEGER, metadata BLOB, action INTEGER, rolled_back INTEGER);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "item")) {
|
if (!tableData.contains(prefix + "item")) {
|
||||||
statement.executeUpdate(
|
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "item (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, type INTEGER, data BLOB, amount INTEGER, action INTEGER, rolled_back INTEGER);");
|
+ "item (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, type INTEGER, data BLOB, amount INTEGER, action INTEGER, rolled_back INTEGER);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "database_lock")) {
|
if (!tableData.contains(prefix + "database_lock")) {
|
||||||
|
|
||||||
statement.executeUpdate(
|
statement.executeUpdate(
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix + "database_lock (status INTEGER, time INTEGER);");
|
"CREATE TABLE IF NOT EXISTS " + prefix + "database_lock (status INTEGER, time INTEGER);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "entity")) {
|
if (!tableData.contains(prefix + "entity")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "entity (id INTEGER PRIMARY KEY ASC, time INTEGER, data BLOB);");
|
+ "entity (id INTEGER PRIMARY KEY ASC, time INTEGER, data BLOB);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "entity_map")) {
|
if (!tableData.contains(prefix + "entity_map")) {
|
||||||
|
|
||||||
statement.executeUpdate(
|
statement.executeUpdate(
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix + "entity_map (id INTEGER, entity TEXT);");
|
"CREATE TABLE IF NOT EXISTS " + prefix + "entity_map (id INTEGER, entity TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "material_map")) {
|
if (!tableData.contains(prefix + "material_map")) {
|
||||||
|
|
||||||
statement.executeUpdate(
|
statement.executeUpdate(
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix + "material_map (id INTEGER, material TEXT);");
|
"CREATE TABLE IF NOT EXISTS " + prefix + "material_map (id INTEGER, material TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "blockdata_map")) {
|
if (!tableData.contains(prefix + "blockdata_map")) {
|
||||||
|
|
||||||
statement.executeUpdate(
|
statement.executeUpdate(
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix + "blockdata_map (id INTEGER, data TEXT);");
|
"CREATE TABLE IF NOT EXISTS " + prefix + "blockdata_map (id INTEGER, data TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "session")) {
|
if (!tableData.contains(prefix + "session")) {
|
||||||
statement.executeUpdate(
|
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "session (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, action INTEGER);");
|
+ "session (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, action INTEGER);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "sign")) {
|
if (!tableData.contains(prefix + "sign")) {
|
||||||
statement.executeUpdate(
|
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "sign (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, action INTEGER, color INTEGER, color_secondary INTEGER, data INTEGER, waxed INTEGER, face INTEGER, line_1 TEXT, line_2 TEXT, line_3 TEXT, line_4 TEXT, line_5 TEXT, line_6 TEXT, line_7 TEXT, line_8 TEXT);");
|
+ "sign (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, action INTEGER, color INTEGER, color_secondary INTEGER, data INTEGER, waxed INTEGER, face INTEGER, line_1 TEXT, line_2 TEXT, line_3 TEXT, line_4 TEXT, line_5 TEXT, line_6 TEXT, line_7 TEXT, line_8 TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "skull")) {
|
if (!tableData.contains(prefix + "skull")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "skull (id INTEGER PRIMARY KEY ASC, time INTEGER, owner TEXT, skin TEXT);");
|
+ "skull (id INTEGER PRIMARY KEY ASC, time INTEGER, owner TEXT, skin TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "user")) {
|
if (!tableData.contains(prefix + "user")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "user (id INTEGER PRIMARY KEY ASC, time INTEGER, user TEXT, uuid TEXT);");
|
+ "user (id INTEGER PRIMARY KEY ASC, time INTEGER, user TEXT, uuid TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "username_log")) {
|
if (!tableData.contains(prefix + "username_log")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix
|
||||||
+ "username_log (id INTEGER PRIMARY KEY ASC, time INTEGER, uuid TEXT, user TEXT);");
|
+ "username_log (id INTEGER PRIMARY KEY ASC, time INTEGER, uuid TEXT, user TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "version")) {
|
if (!tableData.contains(prefix + "version")) {
|
||||||
|
|
||||||
statement.executeUpdate(
|
statement.executeUpdate(
|
||||||
"CREATE TABLE IF NOT EXISTS " + prefix + "version (time INTEGER, version TEXT);");
|
"CREATE TABLE IF NOT EXISTS " + prefix + "version (time INTEGER, version TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.contains(prefix + "world")) {
|
if (!tableData.contains(prefix + "world")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "world (id INTEGER, world TEXT);");
|
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "world (id INTEGER, world TEXT);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!indexData.contains("art_map_id_index")) {
|
if (!indexData.contains("art_map_id_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "art_map_id_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "art_map_id_index ON "
|
||||||
+ ConfigHandler.prefix + "art_map(id);");
|
+ ConfigHandler.prefix + "art_map(id);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("block_index")) {
|
if (!indexData.contains("block_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_index ON "
|
||||||
+ ConfigHandler.prefix + "block(wid,x,z,time);");
|
+ ConfigHandler.prefix + "block(wid,x,z,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("block_user_index")) {
|
if (!indexData.contains("block_user_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_user_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_user_index ON "
|
||||||
+ ConfigHandler.prefix + "block(user,time);");
|
+ ConfigHandler.prefix + "block(user,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("block_type_index")) {
|
if (!indexData.contains("block_type_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_type_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_type_index ON "
|
||||||
+ ConfigHandler.prefix + "block(type,time);");
|
+ ConfigHandler.prefix + "block(type,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("blockdata_map_id_index")) {
|
if (!indexData.contains("blockdata_map_id_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
||||||
+ "blockdata_map_id_index ON " + ConfigHandler.prefix + "blockdata_map(id);");
|
+ "blockdata_map_id_index ON " + ConfigHandler.prefix + "blockdata_map(id);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("chat_index")) {
|
if (!indexData.contains("chat_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_index ON "
|
||||||
+ ConfigHandler.prefix + "chat(time);");
|
+ ConfigHandler.prefix + "chat(time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("chat_user_index")) {
|
if (!indexData.contains("chat_user_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_user_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_user_index ON "
|
||||||
+ ConfigHandler.prefix + "chat(user,time);");
|
+ ConfigHandler.prefix + "chat(user,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("chat_wid_index")) {
|
if (!indexData.contains("chat_wid_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_wid_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_wid_index ON "
|
||||||
+ ConfigHandler.prefix + "chat(wid,x,z,time);");
|
+ ConfigHandler.prefix + "chat(wid,x,z,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("command_index")) {
|
if (!indexData.contains("command_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "command_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "command_index ON "
|
||||||
+ ConfigHandler.prefix + "command(time);");
|
+ ConfigHandler.prefix + "command(time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("command_user_index")) {
|
if (!indexData.contains("command_user_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
||||||
+ "command_user_index ON " + ConfigHandler.prefix + "command(user,time);");
|
+ "command_user_index ON " + ConfigHandler.prefix + "command(user,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("command_wid_index")) {
|
if (!indexData.contains("command_wid_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "command_wid_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "command_wid_index ON "
|
||||||
+ ConfigHandler.prefix + "command(wid,x,z,time);");
|
+ ConfigHandler.prefix + "command(wid,x,z,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("container_index")) {
|
if (!indexData.contains("container_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "container_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "container_index ON "
|
||||||
+ ConfigHandler.prefix + "container(wid,x,z,time);");
|
+ ConfigHandler.prefix + "container(wid,x,z,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("container_user_index")) {
|
if (!indexData.contains("container_user_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
||||||
+ "container_user_index ON " + ConfigHandler.prefix + "container(user,time);");
|
+ "container_user_index ON " + ConfigHandler.prefix + "container(user,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("container_type_index")) {
|
if (!indexData.contains("container_type_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
||||||
+ "container_type_index ON " + ConfigHandler.prefix + "container(type,time);");
|
+ "container_type_index ON " + ConfigHandler.prefix + "container(type,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("item_index")) {
|
if (!indexData.contains("item_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_index ON "
|
||||||
+ ConfigHandler.prefix + "item(wid,x,z,time);");
|
+ ConfigHandler.prefix + "item(wid,x,z,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("item_user_index")) {
|
if (!indexData.contains("item_user_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_user_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_user_index ON "
|
||||||
+ ConfigHandler.prefix + "item(user,time);");
|
+ ConfigHandler.prefix + "item(user,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("item_type_index")) {
|
if (!indexData.contains("item_type_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_type_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_type_index ON "
|
||||||
+ ConfigHandler.prefix + "item(type,time);");
|
+ ConfigHandler.prefix + "item(type,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("entity_map_id_index")) {
|
if (!indexData.contains("entity_map_id_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
||||||
+ "entity_map_id_index ON " + ConfigHandler.prefix + "entity_map(id);");
|
+ "entity_map_id_index ON " + ConfigHandler.prefix + "entity_map(id);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("material_map_id_index")) {
|
if (!indexData.contains("material_map_id_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
||||||
+ "material_map_id_index ON " + ConfigHandler.prefix + "material_map(id);");
|
+ "material_map_id_index ON " + ConfigHandler.prefix + "material_map(id);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("session_index")) {
|
if (!indexData.contains("session_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "session_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "session_index ON "
|
||||||
+ ConfigHandler.prefix + "session(wid,x,z,time);");
|
+ ConfigHandler.prefix + "session(wid,x,z,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("session_action_index")) {
|
if (!indexData.contains("session_action_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
||||||
+ "session_action_index ON " + ConfigHandler.prefix + "session(action,time);");
|
+ "session_action_index ON " + ConfigHandler.prefix + "session(action,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("session_user_index")) {
|
if (!indexData.contains("session_user_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
||||||
+ "session_user_index ON " + ConfigHandler.prefix + "session(user,time);");
|
+ "session_user_index ON " + ConfigHandler.prefix + "session(user,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("session_time_index")) {
|
if (!indexData.contains("session_time_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
||||||
+ "session_time_index ON " + ConfigHandler.prefix + "session(time);");
|
+ "session_time_index ON " + ConfigHandler.prefix + "session(time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("sign_index")) {
|
if (!indexData.contains("sign_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_index ON "
|
||||||
+ ConfigHandler.prefix + "sign(wid,x,z,time);");
|
+ ConfigHandler.prefix + "sign(wid,x,z,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("sign_user_index")) {
|
if (!indexData.contains("sign_user_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_user_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_user_index ON "
|
||||||
+ ConfigHandler.prefix + "sign(user,time);");
|
+ ConfigHandler.prefix + "sign(user,time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("sign_time_index")) {
|
if (!indexData.contains("sign_time_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_time_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_time_index ON "
|
||||||
+ ConfigHandler.prefix + "sign(time);");
|
+ ConfigHandler.prefix + "sign(time);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("user_index")) {
|
if (!indexData.contains("user_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "user_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "user_index ON "
|
||||||
+ ConfigHandler.prefix + "user(user);");
|
+ ConfigHandler.prefix + "user(user);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("uuid_index")) {
|
if (!indexData.contains("uuid_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "uuid_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "uuid_index ON "
|
||||||
+ ConfigHandler.prefix + "user(uuid);");
|
+ ConfigHandler.prefix + "user(uuid);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("username_log_uuid_index")) {
|
if (!indexData.contains("username_log_uuid_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase
|
||||||
+ "username_log_uuid_index ON " + ConfigHandler.prefix + "username_log(uuid,user);");
|
+ "username_log_uuid_index ON " + ConfigHandler.prefix + "username_log(uuid,user);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indexData.contains("world_id_index")) {
|
if (!indexData.contains("world_id_index")) {
|
||||||
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "world_id_index ON "
|
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "world_id_index ON "
|
||||||
+ ConfigHandler.prefix + "world(id);");
|
+ ConfigHandler.prefix + "world(id);");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
Chat.console(Phrase.build(Phrase.DATABASE_INDEX_ERROR));
|
Chat.console(Phrase.build(Phrase.DATABASE_INDEX_ERROR));
|
||||||
if (purge) {
|
if (purge) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!purge && forceConnection == null) {
|
if (!purge && forceConnection == null) {
|
||||||
|
|
||||||
initializeTables(prefix, statement);
|
initializeTables(prefix, statement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -19,50 +19,63 @@ import org.bukkit.Material;
|
|||||||
public class BlockBreakLogger {
|
public class BlockBreakLogger {
|
||||||
|
|
||||||
private BlockBreakLogger() {
|
private BlockBreakLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, int batchCount, String user, Location location, int type,
|
||||||
PreparedStatement preparedStmt,
|
int data, List<Object> meta, String blockData, String overrideData)
|
||||||
int batchCount,
|
{
|
||||||
String user,
|
|
||||||
Location location,
|
|
||||||
int type,
|
|
||||||
int data,
|
|
||||||
List<Object> meta,
|
|
||||||
String blockData,
|
|
||||||
String overrideData) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || location == null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || location == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Material checkType = Util.getType(type);
|
Material checkType = Util.getType(type);
|
||||||
if (checkType == null) {
|
if (checkType == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (checkType.equals(Material.AIR) || checkType.equals(Material.CAVE_AIR)) {
|
} else if (checkType.equals(Material.AIR) || checkType.equals(Material.CAVE_AIR)) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(checkType.getKey().toString()) != null) {
|
if (ConfigHandler.blacklist.get(checkType.getKey().toString()) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.startsWith("#")) {
|
if (!user.startsWith("#")) {
|
||||||
|
|
||||||
String cacheId = location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ() + "."
|
String cacheId = location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ() + "."
|
||||||
+ Util.getWorldId(location.getWorld().getName());
|
+ Util.getWorldId(location.getWorld().getName());
|
||||||
CacheHandler.spreadCache.remove(cacheId);
|
CacheHandler.spreadCache.remove(cacheId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkType == Material.LECTERN) {
|
if (checkType == Material.LECTERN) {
|
||||||
|
|
||||||
blockData = blockData.replaceFirst("has_book=true", "has_book=false");
|
blockData = blockData.replaceFirst("has_book=true", "has_book=false");
|
||||||
|
|
||||||
} else if (checkType == Material.PAINTING || BukkitAdapter.ADAPTER.isItemFrame(checkType)) {
|
} else if (checkType == Material.PAINTING || BukkitAdapter.ADAPTER.isItemFrame(checkType)) {
|
||||||
|
|
||||||
blockData = overrideData;
|
blockData = overrideData;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||||
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
||||||
|
|
||||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||||
@@ -71,17 +84,25 @@ public class BlockBreakLogger {
|
|||||||
int x = location.getBlockX();
|
int x = location.getBlockX();
|
||||||
int y = location.getBlockY();
|
int y = location.getBlockY();
|
||||||
int z = location.getBlockZ();
|
int z = location.getBlockZ();
|
||||||
CacheHandler.breakCache.put(
|
CacheHandler.breakCache.put("" + x + "." + y + "." + z + "." + wid + "",
|
||||||
"" + x + "." + y + "." + z + "." + wid + "", new Object[] {time, event.getUser(), type});
|
new Object[]
|
||||||
|
{ time, event.getUser(), type });
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockStatement.insert(
|
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, type, data, meta, blockData, 0,
|
||||||
preparedStmt, batchCount, time, userId, wid, x, y, z, type, data, meta, blockData, 0, 0);
|
0);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,71 +19,78 @@ import org.bukkit.block.BlockState;
|
|||||||
public class BlockPlaceLogger {
|
public class BlockPlaceLogger {
|
||||||
|
|
||||||
private BlockPlaceLogger() {
|
private BlockPlaceLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, int batchCount, String user, BlockState block,
|
||||||
PreparedStatement preparedStmt,
|
int replacedType, int replacedData, Material forceType, int forceData, boolean force, List<Object> meta,
|
||||||
int batchCount,
|
String blockData, String replaceBlockData)
|
||||||
String user,
|
{
|
||||||
BlockState block,
|
|
||||||
int replacedType,
|
|
||||||
int replacedData,
|
|
||||||
Material forceType,
|
|
||||||
int forceData,
|
|
||||||
boolean force,
|
|
||||||
List<Object> meta,
|
|
||||||
String blockData,
|
|
||||||
String replaceBlockData) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (user == null || ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (user == null || ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Material type = block.getType();
|
Material type = block.getType();
|
||||||
if (blockData == null
|
if (blockData == null
|
||||||
&& (forceType == null
|
&& (forceType == null || (!forceType.equals(Material.WATER)) && (!forceType.equals(Material.LAVA))))
|
||||||
|| (!forceType.equals(Material.WATER)) && (!forceType.equals(Material.LAVA)))) {
|
{
|
||||||
|
|
||||||
blockData = block.getBlockData().getAsString();
|
blockData = block.getBlockData().getAsString();
|
||||||
if (blockData.equals("minecraft:air")) {
|
if (blockData.equals("minecraft:air")) {
|
||||||
|
|
||||||
blockData = null;
|
blockData = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int data = 0;
|
int data = 0;
|
||||||
if (forceType != null && force) {
|
if (forceType != null && force) {
|
||||||
|
|
||||||
type = forceType;
|
type = forceType;
|
||||||
if (BukkitAdapter.ADAPTER.isItemFrame(type)
|
if (BukkitAdapter.ADAPTER.isItemFrame(type) || type.equals(Material.SPAWNER)
|
||||||
|| type.equals(Material.SPAWNER)
|
|| type.equals(Material.PAINTING) || type.equals(Material.SKELETON_SKULL)
|
||||||
|| type.equals(Material.PAINTING)
|
|| type.equals(Material.SKELETON_WALL_SKULL) || type.equals(Material.WITHER_SKELETON_SKULL)
|
||||||
|| type.equals(Material.SKELETON_SKULL)
|
|| type.equals(Material.WITHER_SKELETON_WALL_SKULL) || type.equals(Material.ZOMBIE_HEAD)
|
||||||
|| type.equals(Material.SKELETON_WALL_SKULL)
|
|| type.equals(Material.ZOMBIE_WALL_HEAD) || type.equals(Material.PLAYER_HEAD)
|
||||||
|| type.equals(Material.WITHER_SKELETON_SKULL)
|
|| type.equals(Material.PLAYER_WALL_HEAD) || type.equals(Material.CREEPER_HEAD)
|
||||||
|| type.equals(Material.WITHER_SKELETON_WALL_SKULL)
|
|| type.equals(Material.CREEPER_WALL_HEAD) || type.equals(Material.DRAGON_HEAD)
|
||||||
|| type.equals(Material.ZOMBIE_HEAD)
|
|| type.equals(Material.DRAGON_WALL_HEAD) || type.equals(Material.ARMOR_STAND)
|
||||||
|| type.equals(Material.ZOMBIE_WALL_HEAD)
|
|| type.equals(Material.END_CRYSTAL))
|
||||||
|| type.equals(Material.PLAYER_HEAD)
|
{
|
||||||
|| type.equals(Material.PLAYER_WALL_HEAD)
|
|
||||||
|| type.equals(Material.CREEPER_HEAD)
|
|
||||||
|| type.equals(Material.CREEPER_WALL_HEAD)
|
|
||||||
|| type.equals(Material.DRAGON_HEAD)
|
|
||||||
|| type.equals(Material.DRAGON_WALL_HEAD)
|
|
||||||
|| type.equals(Material.ARMOR_STAND)
|
|
||||||
|| type.equals(Material.END_CRYSTAL)) {
|
|
||||||
data = forceData; // mob spawner, skull
|
data = forceData; // mob spawner, skull
|
||||||
|
|
||||||
} else if (user.startsWith("#")) {
|
} else if (user.startsWith("#")) {
|
||||||
|
|
||||||
data = forceData;
|
data = forceData;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (forceType != null && !type.equals(forceType)) {
|
} else if (forceType != null && !type.equals(forceType)) {
|
||||||
|
|
||||||
type = forceType;
|
type = forceType;
|
||||||
data = forceData;
|
data = forceData;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.equals(Material.AIR) || type.equals(Material.CAVE_AIR)) {
|
if (type.equals(Material.AIR) || type.equals(Material.CAVE_AIR)) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(type.getKey().toString()) != null) {
|
if (ConfigHandler.blacklist.get(type.getKey().toString()) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = block.getX();
|
int x = block.getX();
|
||||||
@@ -91,28 +98,40 @@ public class BlockPlaceLogger {
|
|||||||
int z = block.getZ();
|
int z = block.getZ();
|
||||||
long chunkKey = (x >> 4) & 0xffffffffL | ((z >> 4) & 0xffffffffL) << 32;
|
long chunkKey = (x >> 4) & 0xffffffffL | ((z >> 4) & 0xffffffffL) << 32;
|
||||||
if (ConfigHandler.populatedChunks.get(chunkKey) != null) {
|
if (ConfigHandler.populatedChunks.get(chunkKey) != null) {
|
||||||
|
|
||||||
boolean isWater = user.equals("#water");
|
boolean isWater = user.equals("#water");
|
||||||
boolean isLava = user.equals("#lava");
|
boolean isLava = user.equals("#lava");
|
||||||
boolean isVine = user.equals("#vine");
|
boolean isVine = user.equals("#vine");
|
||||||
if (isWater || isLava || isVine) {
|
if (isWater || isLava || isVine) {
|
||||||
|
|
||||||
int timeDelay = isWater ? 60 : 240;
|
int timeDelay = isWater ? 60 : 240;
|
||||||
long timeSincePopulation = ((System.currentTimeMillis() / 1000L)
|
long timeSincePopulation = ((System.currentTimeMillis() / 1000L)
|
||||||
- ConfigHandler.populatedChunks.getOrDefault(chunkKey, 0L));
|
- ConfigHandler.populatedChunks.getOrDefault(chunkKey, 0L));
|
||||||
if (timeSincePopulation <= timeDelay) {
|
if (timeSincePopulation <= timeDelay) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeSincePopulation > 240) {
|
if (timeSincePopulation > 240) {
|
||||||
|
|
||||||
ConfigHandler.populatedChunks.remove(chunkKey);
|
ConfigHandler.populatedChunks.remove(chunkKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type == Material.WATER || type == Material.LAVA) {
|
} else if (type == Material.WATER || type == Material.LAVA) {
|
||||||
|
|
||||||
ConfigHandler.populatedChunks.remove(chunkKey);
|
ConfigHandler.populatedChunks.remove(chunkKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||||
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
||||||
|
|
||||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||||
@@ -120,39 +139,38 @@ public class BlockPlaceLogger {
|
|||||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||||
|
|
||||||
if (event.getUser().length() > 0) {
|
if (event.getUser().length() > 0) {
|
||||||
CacheHandler.lookupCache.put(
|
|
||||||
"" + x + "." + y + "." + z + "." + wid + "", new Object[] {time, event.getUser(), type});
|
CacheHandler.lookupCache.put("" + x + "." + y + "." + z + "." + wid + "",
|
||||||
|
new Object[]
|
||||||
|
{ time, event.getUser(), type });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int internalType = Util.getBlockId(type.name(), true);
|
int internalType = Util.getBlockId(type.name(), true);
|
||||||
if (replacedType > 0
|
if (replacedType > 0 && Util.getType(replacedType) != Material.AIR
|
||||||
&& Util.getType(replacedType) != Material.AIR
|
&& Util.getType(replacedType) != Material.CAVE_AIR)
|
||||||
&& Util.getType(replacedType) != Material.CAVE_AIR) {
|
{
|
||||||
BlockStatement.insert(
|
|
||||||
preparedStmt,
|
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, replacedType, replacedData,
|
||||||
batchCount,
|
null, replaceBlockData, 0, 0);
|
||||||
time,
|
|
||||||
userId,
|
|
||||||
wid,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
z,
|
|
||||||
replacedType,
|
|
||||||
replacedData,
|
|
||||||
null,
|
|
||||||
replaceBlockData,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockStatement.insert(
|
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, internalType, data, meta,
|
||||||
preparedStmt, batchCount, time, userId, wid, x, y, z, internalType, data, meta, blockData, 1, 0);
|
blockData, 1, 0);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,23 +10,36 @@ import org.bukkit.Location;
|
|||||||
public class ChatLogger {
|
public class ChatLogger {
|
||||||
|
|
||||||
private ChatLogger() {
|
private ChatLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, int batchCount, long time, Location location, String user,
|
||||||
PreparedStatement preparedStmt, int batchCount, long time, Location location, String user, String message) {
|
String message)
|
||||||
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = location.getBlockX();
|
int x = location.getBlockX();
|
||||||
int y = location.getBlockY();
|
int y = location.getBlockY();
|
||||||
int z = location.getBlockZ();
|
int z = location.getBlockZ();
|
||||||
int wid = Util.getWorldId(location.getWorld().getName());
|
int wid = Util.getWorldId(location.getWorld().getName());
|
||||||
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||||
ChatStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, message);
|
ChatStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -15,26 +15,40 @@ import org.bukkit.Location;
|
|||||||
public class CommandLogger {
|
public class CommandLogger {
|
||||||
|
|
||||||
private CommandLogger() {
|
private CommandLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, int batchCount, long time, Location location, String user,
|
||||||
PreparedStatement preparedStmt, int batchCount, long time, Location location, String user, String message) {
|
String message)
|
||||||
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(((message + " ").split(" "))[0].toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.blacklist.get(((message + " ").split(" "))[0].toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||||
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
||||||
|
|
||||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||||
@@ -43,8 +57,13 @@ public class CommandLogger {
|
|||||||
int y = location.getBlockY();
|
int y = location.getBlockY();
|
||||||
int z = location.getBlockZ();
|
int z = location.getBlockZ();
|
||||||
CommandStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, message);
|
CommandStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, message);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,28 +11,36 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class ContainerBreakLogger {
|
public class ContainerBreakLogger {
|
||||||
|
|
||||||
private ContainerBreakLogger() {
|
private ContainerBreakLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, int batchCount, String player, Location l, Material type,
|
||||||
PreparedStatement preparedStmt,
|
ItemStack[] oldInventory)
|
||||||
int batchCount,
|
{
|
||||||
String player,
|
|
||||||
Location l,
|
|
||||||
Material type,
|
|
||||||
ItemStack[] oldInventory) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Util.mergeItems(type, oldInventory);
|
Util.mergeItems(type, oldInventory);
|
||||||
ContainerLogger.logTransaction(preparedStmt, batchCount, player, type, null, oldInventory, 0, l);
|
ContainerLogger.logTransaction(preparedStmt, batchCount, player, type, null, oldInventory, 0, l);
|
||||||
String loggingContainerId =
|
String loggingContainerId = player.toLowerCase(Locale.ROOT) + "." + l.getBlockX() + "." + l.getBlockY()
|
||||||
player.toLowerCase(Locale.ROOT) + "." + l.getBlockX() + "." + l.getBlockY() + "." + l.getBlockZ();
|
+ "." + l.getBlockZ();
|
||||||
|
|
||||||
// If there was a pending chest transaction, it would have already been processed.
|
// If there was a pending chest transaction, it would have already been
|
||||||
|
// processed.
|
||||||
if (ConfigHandler.forceContainer.get(loggingContainerId) != null) {
|
if (ConfigHandler.forceContainer.get(loggingContainerId) != null) {
|
||||||
|
|
||||||
ConfigHandler.forceContainer.remove(loggingContainerId);
|
ConfigHandler.forceContainer.remove(loggingContainerId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,35 +25,44 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public class ContainerLogger extends Queue {
|
public class ContainerLogger extends Queue {
|
||||||
|
|
||||||
private ContainerLogger() {
|
private ContainerLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmtContainer, PreparedStatement preparedStmtItems, int batchCount,
|
||||||
PreparedStatement preparedStmtContainer,
|
String player, Material type, Object container, Location location)
|
||||||
PreparedStatement preparedStmtItems,
|
{
|
||||||
int batchCount,
|
|
||||||
String player,
|
|
||||||
Material type,
|
|
||||||
Object container,
|
|
||||||
Location location) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ItemStack[] contents = null;
|
ItemStack[] contents = null;
|
||||||
String faceData = null;
|
String faceData = null;
|
||||||
|
|
||||||
if (type == Material.ITEM_FRAME) {
|
if (type == Material.ITEM_FRAME) {
|
||||||
|
|
||||||
contents = (ItemStack[]) ((Object[]) container)[1];
|
contents = (ItemStack[]) ((Object[]) container)[1];
|
||||||
faceData = ((BlockFace) ((Object[]) container)[2]).name();
|
faceData = ((BlockFace) ((Object[]) container)[2]).name();
|
||||||
|
|
||||||
} else if (type == Material.JUKEBOX || type == Material.ARMOR_STAND) {
|
} else if (type == Material.JUKEBOX || type == Material.ARMOR_STAND) {
|
||||||
|
|
||||||
contents = (ItemStack[]) ((Object[]) container)[1];
|
contents = (ItemStack[]) ((Object[]) container)[1];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Inventory inventory = (Inventory) container;
|
Inventory inventory = (Inventory) container;
|
||||||
if (inventory != null) {
|
if (inventory != null) {
|
||||||
|
|
||||||
contents = inventory.getContents();
|
contents = inventory.getContents();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contents == null) {
|
if (contents == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String loggingContainerId = player.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "."
|
String loggingContainerId = player.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "."
|
||||||
@@ -63,138 +72,196 @@ public class ContainerLogger extends Queue {
|
|||||||
ItemStack[] oldInventory = Util.getContainerState(oi1);
|
ItemStack[] oldInventory = Util.getContainerState(oi1);
|
||||||
ItemStack[] newInventory = Util.getContainerState(contents);
|
ItemStack[] newInventory = Util.getContainerState(contents);
|
||||||
if (oldInventory == null || newInventory == null) {
|
if (oldInventory == null || newInventory == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ItemStack[]> forceList = ConfigHandler.forceContainer.get(loggingContainerId);
|
List<ItemStack[]> forceList = ConfigHandler.forceContainer.get(loggingContainerId);
|
||||||
if (forceList != null) {
|
if (forceList != null) {
|
||||||
|
|
||||||
int forceSize = 0;
|
int forceSize = 0;
|
||||||
if (!forceList.isEmpty()) {
|
if (!forceList.isEmpty()) {
|
||||||
|
|
||||||
newInventory = Util.getContainerState(forceList.get(0));
|
newInventory = Util.getContainerState(forceList.get(0));
|
||||||
forceSize = modifyForceContainer(loggingContainerId, null);
|
forceSize = modifyForceContainer(loggingContainerId, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forceSize == 0) {
|
if (forceSize == 0) {
|
||||||
|
|
||||||
ConfigHandler.forceContainer.remove(loggingContainerId);
|
ConfigHandler.forceContainer.remove(loggingContainerId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String transactingChestId = location.getWorld().getUID().toString() + "." + location.getBlockX() + "."
|
String transactingChestId = location.getWorld().getUID().toString() + "." + location.getBlockX() + "."
|
||||||
+ location.getBlockY() + "." + location.getBlockZ();
|
+ location.getBlockY() + "." + location.getBlockZ();
|
||||||
if (ConfigHandler.transactingChest.get(transactingChestId) != null) {
|
if (ConfigHandler.transactingChest.get(transactingChestId) != null) {
|
||||||
List<Object> list = Collections.synchronizedList(
|
|
||||||
new ArrayList<>(ConfigHandler.transactingChest.get(transactingChestId)));
|
List<Object> list = Collections
|
||||||
|
.synchronizedList(new ArrayList<>(ConfigHandler.transactingChest.get(transactingChestId)));
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
|
|
||||||
ItemStack[] newMerge = new ItemStack[newInventory.length + list.size()];
|
ItemStack[] newMerge = new ItemStack[newInventory.length + list.size()];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < newInventory.length; i++) {
|
for (int i = 0; i < newInventory.length; i++) {
|
||||||
|
|
||||||
newMerge[i] = newInventory[i];
|
newMerge[i] = newInventory[i];
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Object item : list) {
|
for (Object item : list) {
|
||||||
|
|
||||||
ItemStack addItem = null;
|
ItemStack addItem = null;
|
||||||
ItemStack removeItem = null;
|
ItemStack removeItem = null;
|
||||||
if (item instanceof ItemStack) {
|
if (item instanceof ItemStack) {
|
||||||
|
|
||||||
addItem = (ItemStack) item;
|
addItem = (ItemStack) item;
|
||||||
|
|
||||||
} else if (item != null) {
|
} else if (item != null) {
|
||||||
|
|
||||||
addItem = ((ItemStack[]) item)[0];
|
addItem = ((ItemStack[]) item)[0];
|
||||||
removeItem = ((ItemStack[]) item)[1];
|
removeItem = ((ItemStack[]) item)[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// item was removed by hopper, add back to state
|
// item was removed by hopper, add back to state
|
||||||
if (addItem != null) {
|
if (addItem != null) {
|
||||||
|
|
||||||
newMerge[count] = addItem;
|
newMerge[count] = addItem;
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// item was added by hopper, remove from state
|
// item was added by hopper, remove from state
|
||||||
if (removeItem != null) {
|
if (removeItem != null) {
|
||||||
|
|
||||||
for (ItemStack check : newMerge) {
|
for (ItemStack check : newMerge) {
|
||||||
|
|
||||||
if (check != null && check.isSimilar(removeItem)) {
|
if (check != null && check.isSimilar(removeItem)) {
|
||||||
|
|
||||||
check.setAmount(check.getAmount() - 1);
|
check.setAmount(check.getAmount() - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newInventory = newMerge;
|
newInventory = newMerge;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack oldi : oldInventory) {
|
for (ItemStack oldi : oldInventory) {
|
||||||
|
|
||||||
for (ItemStack newi : newInventory) {
|
for (ItemStack newi : newInventory) {
|
||||||
|
|
||||||
if (oldi != null && newi != null) {
|
if (oldi != null && newi != null) {
|
||||||
|
|
||||||
if (oldi.isSimilar(newi) && !Util.isAir(oldi.getType())) { // Ignores amount
|
if (oldi.isSimilar(newi) && !Util.isAir(oldi.getType())) { // Ignores amount
|
||||||
|
|
||||||
int oldAmount = oldi.getAmount();
|
int oldAmount = oldi.getAmount();
|
||||||
int newAmount = newi.getAmount();
|
int newAmount = newi.getAmount();
|
||||||
if (newAmount >= oldAmount) {
|
if (newAmount >= oldAmount) {
|
||||||
|
|
||||||
newAmount = newAmount - oldAmount;
|
newAmount = newAmount - oldAmount;
|
||||||
oldi.setAmount(0);
|
oldi.setAmount(0);
|
||||||
newi.setAmount(newAmount);
|
newi.setAmount(newAmount);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
oldAmount = oldAmount - newAmount;
|
oldAmount = oldAmount - newAmount;
|
||||||
oldi.setAmount(oldAmount);
|
oldi.setAmount(oldAmount);
|
||||||
newi.setAmount(0);
|
newi.setAmount(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.mergeItems(type, oldInventory);
|
Util.mergeItems(type, oldInventory);
|
||||||
Util.mergeItems(type, newInventory);
|
Util.mergeItems(type, newInventory);
|
||||||
|
|
||||||
if (type != Material.ENDER_CHEST) {
|
if (type != Material.ENDER_CHEST) {
|
||||||
|
|
||||||
logTransaction(preparedStmtContainer, batchCount, player, type, faceData, oldInventory, 0, location);
|
logTransaction(preparedStmtContainer, batchCount, player, type, faceData, oldInventory, 0, location);
|
||||||
logTransaction(preparedStmtContainer, batchCount, player, type, faceData, newInventory, 1, location);
|
logTransaction(preparedStmtContainer, batchCount, player, type, faceData, newInventory, 1, location);
|
||||||
|
|
||||||
} else { // pass ender chest transactions to item logger
|
} else { // pass ender chest transactions to item logger
|
||||||
ItemLogger.logTransaction(
|
|
||||||
preparedStmtItems, batchCount, 0, player, location, oldInventory, ItemLogger.ITEM_REMOVE_ENDER);
|
ItemLogger.logTransaction(preparedStmtItems, batchCount, 0, player, location, oldInventory,
|
||||||
ItemLogger.logTransaction(
|
ItemLogger.ITEM_REMOVE_ENDER);
|
||||||
preparedStmtItems, batchCount, 0, player, location, newInventory, ItemLogger.ITEM_ADD_ENDER);
|
ItemLogger.logTransaction(preparedStmtItems, batchCount, 0, player, location, newInventory,
|
||||||
|
ItemLogger.ITEM_ADD_ENDER);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oldList.remove(0);
|
oldList.remove(0);
|
||||||
ConfigHandler.oldContainer.put(loggingContainerId, oldList);
|
ConfigHandler.oldContainer.put(loggingContainerId, oldList);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void logTransaction(
|
protected static void logTransaction(PreparedStatement preparedStmt, int batchCount, String user, Material type,
|
||||||
PreparedStatement preparedStmt,
|
String faceData, ItemStack[] items, int action, Location location)
|
||||||
int batchCount,
|
{
|
||||||
String user,
|
|
||||||
Material type,
|
|
||||||
String faceData,
|
|
||||||
ItemStack[] items,
|
|
||||||
int action,
|
|
||||||
Location location) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
for (ItemStack item : items) {
|
for (ItemStack item : items) {
|
||||||
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
|
||||||
if (item.getAmount() > 0 && !Util.isAir(item.getType())) {
|
if (item.getAmount() > 0 && !Util.isAir(item.getType())) {
|
||||||
|
|
||||||
// Object[] metadata = new Object[] { slot, item.getItemMeta() };
|
// Object[] metadata = new Object[] { slot, item.getItemMeta() };
|
||||||
List<List<Map<String, Object>>> metadata =
|
List<List<Map<String, Object>>> metadata = ItemMetaHandler.serialize(item, type, faceData,
|
||||||
ItemMetaHandler.serialize(item, type, faceData, slot);
|
slot);
|
||||||
if (metadata.size() == 0) {
|
if (metadata.size() == 0) {
|
||||||
|
|
||||||
metadata = null;
|
metadata = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||||
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
||||||
CoreProtect.getInstance()
|
|
||||||
.getServer()
|
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
.getPluginManager()
|
|
||||||
.callEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||||
@@ -206,35 +273,33 @@ public class ContainerLogger extends Queue {
|
|||||||
int typeId = Util.getBlockId(item.getType().name(), true);
|
int typeId = Util.getBlockId(item.getType().name(), true);
|
||||||
int data = 0;
|
int data = 0;
|
||||||
int amount = item.getAmount();
|
int amount = item.getAmount();
|
||||||
ContainerStatement.insert(
|
ContainerStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, typeId, data,
|
||||||
preparedStmt,
|
amount, metadata, action, 0);
|
||||||
batchCount,
|
|
||||||
time,
|
|
||||||
userId,
|
|
||||||
wid,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
z,
|
|
||||||
typeId,
|
|
||||||
data,
|
|
||||||
amount,
|
|
||||||
metadata,
|
|
||||||
action,
|
|
||||||
0);
|
|
||||||
success = true;
|
success = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slot++;
|
slot++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success && user.equals("#hopper")) {
|
if (success && user.equals("#hopper")) {
|
||||||
|
|
||||||
String hopperPush = "#hopper-push." + location.getBlockX() + "." + location.getBlockY() + "."
|
String hopperPush = "#hopper-push." + location.getBlockX() + "." + location.getBlockY() + "."
|
||||||
+ location.getBlockZ();
|
+ location.getBlockZ();
|
||||||
ConfigHandler.hopperSuccess.remove(hopperPush);
|
ConfigHandler.hopperSuccess.remove(hopperPush);
|
||||||
ConfigHandler.hopperAbort.remove(hopperPush);
|
ConfigHandler.hopperAbort.remove(hopperPush);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,29 +19,34 @@ import org.bukkit.block.BlockState;
|
|||||||
public class EntityKillLogger {
|
public class EntityKillLogger {
|
||||||
|
|
||||||
private EntityKillLogger() {
|
private EntityKillLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, PreparedStatement preparedStmt2, int batchCount, String user,
|
||||||
PreparedStatement preparedStmt,
|
BlockState block, List<Object> data, int type)
|
||||||
PreparedStatement preparedStmt2,
|
{
|
||||||
int batchCount,
|
|
||||||
String user,
|
|
||||||
BlockState block,
|
|
||||||
List<Object> data,
|
|
||||||
int type) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||||
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
||||||
|
|
||||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||||
@@ -54,20 +59,29 @@ public class EntityKillLogger {
|
|||||||
|
|
||||||
ResultSet resultSet = EntityStatement.insert(preparedStmt2, time, data);
|
ResultSet resultSet = EntityStatement.insert(preparedStmt2, time, data);
|
||||||
if (Database.hasReturningKeys()) {
|
if (Database.hasReturningKeys()) {
|
||||||
|
|
||||||
resultSet.next();
|
resultSet.next();
|
||||||
entity_key = resultSet.getInt(1);
|
entity_key = resultSet.getInt(1);
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
||||||
keys.next();
|
keys.next();
|
||||||
entity_key = keys.getInt(1);
|
entity_key = keys.getInt(1);
|
||||||
keys.close();
|
keys.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockStatement.insert(
|
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, type, entity_key, null, null, 3,
|
||||||
preparedStmt, batchCount, time, userId, wid, x, y, z, type, entity_key, null, null, 3, 0);
|
0);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -34,13 +34,19 @@ public class ItemLogger {
|
|||||||
public static final int ITEM_BUY = 12;
|
public static final int ITEM_BUY = 12;
|
||||||
|
|
||||||
private ItemLogger() {
|
private ItemLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(PreparedStatement preparedStmt, int batchCount, Location location, int offset, String user) {
|
public static void log(PreparedStatement preparedStmt, int batchCount, Location location, int offset, String user) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String loggingItemId = user.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "."
|
String loggingItemId = user.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "."
|
||||||
@@ -109,35 +115,44 @@ public class ItemLogger {
|
|||||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemCreates, ITEM_CREATE);
|
logTransaction(preparedStmt, batchCount, offset, user, location, itemCreates, ITEM_CREATE);
|
||||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemSells, ITEM_SELL);
|
logTransaction(preparedStmt, batchCount, offset, user, location, itemSells, ITEM_SELL);
|
||||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemBuys, ITEM_BUY);
|
logTransaction(preparedStmt, batchCount, offset, user, location, itemBuys, ITEM_BUY);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void logTransaction(
|
protected static void logTransaction(PreparedStatement preparedStmt, int batchCount, int offset, String user,
|
||||||
PreparedStatement preparedStmt,
|
Location location, ItemStack[] items, int action)
|
||||||
int batchCount,
|
{
|
||||||
int offset,
|
|
||||||
String user,
|
|
||||||
Location location,
|
|
||||||
ItemStack[] items,
|
|
||||||
int action) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
for (ItemStack item : items) {
|
for (ItemStack item : items) {
|
||||||
|
|
||||||
if (item != null && item.getAmount() > 0 && !Util.isAir(item.getType())) {
|
if (item != null && item.getAmount() > 0 && !Util.isAir(item.getType())) {
|
||||||
|
|
||||||
// Object[] metadata = new Object[] { slot, item.getItemMeta() };
|
// Object[] metadata = new Object[] { slot, item.getItemMeta() };
|
||||||
List<List<Map<String, Object>>> data = ItemMetaHandler.serialize(item, null, null, 0);
|
List<List<Map<String, Object>>> data = ItemMetaHandler.serialize(item, null, null, 0);
|
||||||
if (data.size() == 0) {
|
if (data.size() == 0) {
|
||||||
|
|
||||||
data = null;
|
data = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||||
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
||||||
|
|
||||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||||
@@ -148,12 +163,19 @@ public class ItemLogger {
|
|||||||
int z = location.getBlockZ();
|
int z = location.getBlockZ();
|
||||||
int typeId = Util.getBlockId(item.getType().name(), true);
|
int typeId = Util.getBlockId(item.getType().name(), true);
|
||||||
int amount = item.getAmount();
|
int amount = item.getAmount();
|
||||||
ItemStatement.insert(
|
ItemStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, typeId, data, amount,
|
||||||
preparedStmt, batchCount, time, userId, wid, x, y, z, typeId, data, amount, action);
|
action);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,26 +16,37 @@ import org.bukkit.block.BlockState;
|
|||||||
public class PlayerInteractLogger {
|
public class PlayerInteractLogger {
|
||||||
|
|
||||||
private PlayerInteractLogger() {
|
private PlayerInteractLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, int batchCount, String user, BlockState block,
|
||||||
PreparedStatement preparedStmt, int batchCount, String user, BlockState block, Material blockType) {
|
Material blockType)
|
||||||
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
int type = Util.getBlockId(blockType.name(), true);
|
int type = Util.getBlockId(blockType.name(), true);
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null
|
||||||
|| Util.getType(type).equals(Material.AIR)
|
|| Util.getType(type).equals(Material.AIR) || Util.getType(type).equals(Material.CAVE_AIR))
|
||||||
|| Util.getType(type).equals(Material.CAVE_AIR)) {
|
{
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||||
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
||||||
|
|
||||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||||
@@ -46,8 +57,13 @@ public class PlayerInteractLogger {
|
|||||||
int z = block.getZ();
|
int z = block.getZ();
|
||||||
int data = 0;
|
int data = 0;
|
||||||
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, type, data, null, null, 2, 0);
|
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, type, data, null, null, 2, 0);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -15,27 +15,40 @@ import org.bukkit.block.BlockState;
|
|||||||
public class PlayerKillLogger {
|
public class PlayerKillLogger {
|
||||||
|
|
||||||
private PlayerKillLogger() {
|
private PlayerKillLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, int batchCount, String user, BlockState block,
|
||||||
PreparedStatement preparedStmt, int batchCount, String user, BlockState block, String player) {
|
String player)
|
||||||
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.playerIdCache.get(player.toLowerCase(Locale.ROOT)) == null) {
|
if (ConfigHandler.playerIdCache.get(player.toLowerCase(Locale.ROOT)) == null) {
|
||||||
|
|
||||||
UserStatement.loadId(preparedStmt.getConnection(), player, null);
|
UserStatement.loadId(preparedStmt.getConnection(), player, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||||
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
||||||
|
|
||||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||||
@@ -46,8 +59,13 @@ public class PlayerKillLogger {
|
|||||||
int y = block.getY();
|
int y = block.getY();
|
||||||
int z = block.getZ();
|
int z = block.getZ();
|
||||||
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, 0, playerId, null, null, 3, 0);
|
BlockStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, 0, playerId, null, null, 3, 0);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,23 +10,36 @@ import org.bukkit.Location;
|
|||||||
public class PlayerSessionLogger {
|
public class PlayerSessionLogger {
|
||||||
|
|
||||||
private PlayerSessionLogger() {
|
private PlayerSessionLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, int batchCount, String user, Location location, int time,
|
||||||
PreparedStatement preparedStmt, int batchCount, String user, Location location, int time, int action) {
|
int action)
|
||||||
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = location.getBlockX();
|
int x = location.getBlockX();
|
||||||
int y = location.getBlockY();
|
int y = location.getBlockY();
|
||||||
int z = location.getBlockZ();
|
int z = location.getBlockZ();
|
||||||
int wid = Util.getWorldId(location.getWorld().getName());
|
int wid = Util.getWorldId(location.getWorld().getName());
|
||||||
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||||
SessionStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, action);
|
SessionStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, action);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -15,41 +15,35 @@ import org.bukkit.Location;
|
|||||||
public class SignTextLogger {
|
public class SignTextLogger {
|
||||||
|
|
||||||
private SignTextLogger() {
|
private SignTextLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, int batchCount, String user, Location location, int action,
|
||||||
PreparedStatement preparedStmt,
|
int color, int colorSecondary, int data, boolean isWaxed, boolean isFront, String line1, String line2,
|
||||||
int batchCount,
|
String line3, String line4, String line5, String line6, String line7, String line8, int timeOffset)
|
||||||
String user,
|
{
|
||||||
Location location,
|
|
||||||
int action,
|
|
||||||
int color,
|
|
||||||
int colorSecondary,
|
|
||||||
int data,
|
|
||||||
boolean isWaxed,
|
|
||||||
boolean isFront,
|
|
||||||
String line1,
|
|
||||||
String line2,
|
|
||||||
String line3,
|
|
||||||
String line4,
|
|
||||||
String line5,
|
|
||||||
String line6,
|
|
||||||
String line7,
|
|
||||||
String line8,
|
|
||||||
int timeOffset) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
CoreProtectPreLogEvent event = new CoreProtectPreLogEvent(user);
|
||||||
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
if (Config.getGlobal().API_ENABLED && !Bukkit.isPrimaryThread()) {
|
||||||
|
|
||||||
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
CoreProtect.getInstance().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
int userId = UserStatement.getId(preparedStmt, event.getUser(), true);
|
||||||
@@ -60,43 +54,32 @@ public class SignTextLogger {
|
|||||||
int z = location.getBlockZ();
|
int z = location.getBlockZ();
|
||||||
|
|
||||||
if (line1.isEmpty() && line2.isEmpty() && line3.isEmpty() && line4.isEmpty()) {
|
if (line1.isEmpty() && line2.isEmpty() && line3.isEmpty() && line4.isEmpty()) {
|
||||||
|
|
||||||
line1 = null;
|
line1 = null;
|
||||||
line2 = null;
|
line2 = null;
|
||||||
line3 = null;
|
line3 = null;
|
||||||
line4 = null;
|
line4 = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line5.isEmpty() && line6.isEmpty() && line7.isEmpty() && line8.isEmpty()) {
|
if (line5.isEmpty() && line6.isEmpty() && line7.isEmpty() && line8.isEmpty()) {
|
||||||
|
|
||||||
line5 = null;
|
line5 = null;
|
||||||
line6 = null;
|
line6 = null;
|
||||||
line7 = null;
|
line7 = null;
|
||||||
line8 = null;
|
line8 = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SignStatement.insert(
|
SignStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, action, color, colorSecondary,
|
||||||
preparedStmt,
|
data, isWaxed ? 1 : 0, isFront ? 0 : 1, line1, line2, line3, line4, line5, line6, line7, line8);
|
||||||
batchCount,
|
|
||||||
time,
|
|
||||||
userId,
|
|
||||||
wid,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
z,
|
|
||||||
action,
|
|
||||||
color,
|
|
||||||
colorSecondary,
|
|
||||||
data,
|
|
||||||
isWaxed ? 1 : 0,
|
|
||||||
isFront ? 0 : 1,
|
|
||||||
line1,
|
|
||||||
line2,
|
|
||||||
line3,
|
|
||||||
line4,
|
|
||||||
line5,
|
|
||||||
line6,
|
|
||||||
line7,
|
|
||||||
line8);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -14,19 +14,23 @@ import org.bukkit.block.Skull;
|
|||||||
public class SkullBreakLogger {
|
public class SkullBreakLogger {
|
||||||
|
|
||||||
private SkullBreakLogger() {
|
private SkullBreakLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, PreparedStatement preparedStmt2, int batchCount, String user,
|
||||||
PreparedStatement preparedStmt,
|
BlockState block)
|
||||||
PreparedStatement preparedStmt2,
|
{
|
||||||
int batchCount,
|
|
||||||
String user,
|
|
||||||
BlockState block) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || block == null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || block == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||||
int type = Util.getBlockId(block.getType().name(), true);
|
int type = Util.getBlockId(block.getType().name(), true);
|
||||||
Skull skull = (Skull) block;
|
Skull skull = (Skull) block;
|
||||||
@@ -34,33 +38,36 @@ public class SkullBreakLogger {
|
|||||||
String skullSkin = null;
|
String skullSkin = null;
|
||||||
int skullKey = 0;
|
int skullKey = 0;
|
||||||
if (skull.hasOwner()) {
|
if (skull.hasOwner()) {
|
||||||
|
|
||||||
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
||||||
skullSkin = PaperAdapter.ADAPTER.getSkullSkin(skull);
|
skullSkin = PaperAdapter.ADAPTER.getSkullSkin(skull);
|
||||||
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner, skullSkin);
|
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner, skullSkin);
|
||||||
if (Database.hasReturningKeys()) {
|
if (Database.hasReturningKeys()) {
|
||||||
|
|
||||||
resultSet.next();
|
resultSet.next();
|
||||||
skullKey = resultSet.getInt(1);
|
skullKey = resultSet.getInt(1);
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
||||||
keys.next();
|
keys.next();
|
||||||
skullKey = keys.getInt(1);
|
skullKey = keys.getInt(1);
|
||||||
keys.close();
|
keys.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockBreakLogger.log(
|
BlockBreakLogger.log(preparedStmt, batchCount, user, block.getLocation(), type, skullKey, null,
|
||||||
preparedStmt,
|
block.getBlockData().getAsString(), null);
|
||||||
batchCount,
|
|
||||||
user,
|
|
||||||
block.getLocation(),
|
|
||||||
type,
|
|
||||||
skullKey,
|
|
||||||
null,
|
|
||||||
block.getBlockData().getAsString(),
|
|
||||||
null);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -14,61 +14,65 @@ import org.bukkit.block.Skull;
|
|||||||
public class SkullPlaceLogger {
|
public class SkullPlaceLogger {
|
||||||
|
|
||||||
private SkullPlaceLogger() {
|
private SkullPlaceLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(
|
public static void log(PreparedStatement preparedStmt, PreparedStatement preparedStmt2, int batchCount, String user,
|
||||||
PreparedStatement preparedStmt,
|
BlockState block, int replaceType, int replaceData)
|
||||||
PreparedStatement preparedStmt2,
|
{
|
||||||
int batchCount,
|
|
||||||
String user,
|
|
||||||
BlockState block,
|
|
||||||
int replaceType,
|
|
||||||
int replaceData) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || block == null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || block == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||||
Material type = block.getType();
|
Material type = block.getType();
|
||||||
int skullKey = 0;
|
int skullKey = 0;
|
||||||
|
|
||||||
if (block instanceof Skull) {
|
if (block instanceof Skull) {
|
||||||
|
|
||||||
Skull skull = (Skull) block;
|
Skull skull = (Skull) block;
|
||||||
String skullOwner = "";
|
String skullOwner = "";
|
||||||
String skullSkin = null;
|
String skullSkin = null;
|
||||||
if (skull.hasOwner()) {
|
if (skull.hasOwner()) {
|
||||||
|
|
||||||
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
skullOwner = PaperAdapter.ADAPTER.getSkullOwner(skull);
|
||||||
skullSkin = PaperAdapter.ADAPTER.getSkullSkin(skull);
|
skullSkin = PaperAdapter.ADAPTER.getSkullSkin(skull);
|
||||||
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner, skullSkin);
|
ResultSet resultSet = SkullStatement.insert(preparedStmt2, time, skullOwner, skullSkin);
|
||||||
if (Database.hasReturningKeys()) {
|
if (Database.hasReturningKeys()) {
|
||||||
|
|
||||||
resultSet.next();
|
resultSet.next();
|
||||||
skullKey = resultSet.getInt(1);
|
skullKey = resultSet.getInt(1);
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
ResultSet keys = preparedStmt2.getGeneratedKeys();
|
||||||
keys.next();
|
keys.next();
|
||||||
skullKey = keys.getInt(1);
|
skullKey = keys.getInt(1);
|
||||||
keys.close();
|
keys.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPlaceLogger.log(
|
BlockPlaceLogger.log(preparedStmt, batchCount, user, block, replaceType, replaceData, type, skullKey, true,
|
||||||
preparedStmt,
|
null, null, null);
|
||||||
batchCount,
|
|
||||||
user,
|
|
||||||
block,
|
|
||||||
replaceType,
|
|
||||||
replaceData,
|
|
||||||
type,
|
|
||||||
skullKey,
|
|
||||||
true,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,13 +9,19 @@ import net.coreprotect.config.ConfigHandler;
|
|||||||
public class UsernameLogger {
|
public class UsernameLogger {
|
||||||
|
|
||||||
private UsernameLogger() {
|
private UsernameLogger() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(Connection connection, String user, String uuid, int configUsernames, int time) {
|
public static void log(Connection connection, String user, String uuid, int configUsernames, int time) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int idRow = -1;
|
int idRow = -1;
|
||||||
@@ -25,21 +31,29 @@ public class UsernameLogger {
|
|||||||
preparedStmt.setString(1, uuid);
|
preparedStmt.setString(1, uuid);
|
||||||
ResultSet rs = preparedStmt.executeQuery();
|
ResultSet rs = preparedStmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
idRow = rs.getInt("id");
|
idRow = rs.getInt("id");
|
||||||
userRow = rs.getString("user").toLowerCase(Locale.ROOT);
|
userRow = rs.getString("user").toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
boolean update = false;
|
boolean update = false;
|
||||||
if (userRow == null) {
|
if (userRow == null) {
|
||||||
|
|
||||||
idRow = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
idRow = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||||
update = true;
|
update = true;
|
||||||
|
|
||||||
} else if (!user.equalsIgnoreCase(userRow)) {
|
} else if (!user.equalsIgnoreCase(userRow)) {
|
||||||
|
|
||||||
update = true;
|
update = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
||||||
preparedStmt = connection.prepareStatement(
|
preparedStmt = connection.prepareStatement(
|
||||||
"UPDATE " + ConfigHandler.prefix + "user SET user = ?, uuid = ? WHERE rowid = ?");
|
"UPDATE " + ConfigHandler.prefix + "user SET user = ?, uuid = ? WHERE rowid = ?");
|
||||||
preparedStmt.setString(1, user);
|
preparedStmt.setString(1, user);
|
||||||
@@ -49,15 +63,13 @@ public class UsernameLogger {
|
|||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//Commented out to prevent potential issues if player manages to stay logged in with old username
|
* //Commented out to prevent potential issues if player manages to stay logged
|
||||||
if (ConfigHandler.playerIdCache.get(user_row)!=null){
|
* in with old username if (ConfigHandler.playerIdCache.get(user_row)!=null){
|
||||||
int cache_id = ConfigHandler.playerIdCache.get(user_row);
|
* int cache_id = ConfigHandler.playerIdCache.get(user_row); if
|
||||||
if (cache_id==id_row){
|
* (cache_id==id_row){ ConfigHandler.playerIdCache.remove(user_row); } }
|
||||||
ConfigHandler.playerIdCache.remove(user_row);
|
*/
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
boolean foundUUID = false;
|
boolean foundUUID = false;
|
||||||
query = "SELECT rowid as id FROM " + ConfigHandler.prefix
|
query = "SELECT rowid as id FROM " + ConfigHandler.prefix
|
||||||
+ "username_log WHERE uuid = ? AND user = ? LIMIT 0, 1";
|
+ "username_log WHERE uuid = ? AND user = ? LIMIT 0, 1";
|
||||||
@@ -66,17 +78,24 @@ public class UsernameLogger {
|
|||||||
preparedStatement.setString(2, user);
|
preparedStatement.setString(2, user);
|
||||||
rs = preparedStatement.executeQuery();
|
rs = preparedStatement.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
foundUUID = true;
|
foundUUID = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
preparedStatement.close();
|
preparedStatement.close();
|
||||||
|
|
||||||
if (!foundUUID) {
|
if (!foundUUID) {
|
||||||
|
|
||||||
update = true;
|
update = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update && configUsernames == 1) {
|
if (update && configUsernames == 1) {
|
||||||
|
|
||||||
preparedStmt = connection.prepareStatement(
|
preparedStmt = connection.prepareStatement(
|
||||||
"INSERT INTO " + ConfigHandler.prefix + "username_log (time, uuid, user) VALUES (?, ?, ?)");
|
"INSERT INTO " + ConfigHandler.prefix + "username_log (time, uuid, user) VALUES (?, ?, ?)");
|
||||||
preparedStmt.setInt(1, time);
|
preparedStmt.setInt(1, time);
|
||||||
@@ -84,14 +103,20 @@ public class UsernameLogger {
|
|||||||
preparedStmt.setString(3, user);
|
preparedStmt.setString(3, user);
|
||||||
preparedStmt.executeUpdate();
|
preparedStmt.executeUpdate();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.playerIdCache.put(user.toLowerCase(Locale.ROOT), idRow);
|
ConfigHandler.playerIdCache.put(user.toLowerCase(Locale.ROOT), idRow);
|
||||||
ConfigHandler.playerIdCacheReversed.put(idRow, user);
|
ConfigHandler.playerIdCacheReversed.put(idRow, user);
|
||||||
ConfigHandler.uuidCache.put(user.toLowerCase(Locale.ROOT), uuid);
|
ConfigHandler.uuidCache.put(user.toLowerCase(Locale.ROOT), uuid);
|
||||||
ConfigHandler.uuidCacheReversed.put(uuid, user);
|
ConfigHandler.uuidCacheReversed.put(uuid, user);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,31 +16,40 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
public class BlockLookup {
|
public class BlockLookup {
|
||||||
|
|
||||||
public static String performLookup(
|
public static String performLookup(String command, Statement statement, BlockState block,
|
||||||
String command,
|
CommandSender commandSender, int offset, int page, int limit)
|
||||||
Statement statement,
|
{
|
||||||
BlockState block,
|
|
||||||
CommandSender commandSender,
|
|
||||||
int offset,
|
|
||||||
int page,
|
|
||||||
int limit) {
|
|
||||||
String resultText = "";
|
String resultText = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
|
|
||||||
return resultText;
|
return resultText;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
|
|
||||||
if (commandSender.hasPermission("coreprotect.co")) {
|
if (commandSender.hasPermission("coreprotect.co")) {
|
||||||
|
|
||||||
command = "co";
|
command = "co";
|
||||||
|
|
||||||
} else if (commandSender.hasPermission("coreprotect.core")) {
|
} else if (commandSender.hasPermission("coreprotect.core")) {
|
||||||
|
|
||||||
command = "core";
|
command = "core";
|
||||||
|
|
||||||
} else if (commandSender.hasPermission("coreprotect.coreprotect")) {
|
} else if (commandSender.hasPermission("coreprotect.coreprotect")) {
|
||||||
|
|
||||||
command = "coreprotect";
|
command = "coreprotect";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
command = "co";
|
command = "co";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@@ -54,7 +63,9 @@ public class BlockLookup {
|
|||||||
int rowMax = page * limit;
|
int rowMax = page * limit;
|
||||||
int page_start = rowMax - limit;
|
int page_start = rowMax - limit;
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
|
|
||||||
checkTime = time - offset;
|
checkTime = time - offset;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String blockName = block.getType().name().toLowerCase(Locale.ROOT);
|
String blockName = block.getType().name().toLowerCase(Locale.ROOT);
|
||||||
@@ -64,8 +75,11 @@ public class BlockLookup {
|
|||||||
+ "' AND y = '" + y + "' AND action IN(0,1) AND time >= '" + checkTime + "' LIMIT 0, 1";
|
+ "' AND y = '" + y + "' AND action IN(0,1) AND time >= '" + checkTime + "' LIMIT 0, 1";
|
||||||
ResultSet results = statement.executeQuery(query);
|
ResultSet results = statement.executeQuery(query);
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
count = results.getInt("count");
|
count = results.getInt("count");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.close();
|
results.close();
|
||||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||||
|
|
||||||
@@ -78,6 +92,7 @@ public class BlockLookup {
|
|||||||
StringBuilder resultTextBuilder = new StringBuilder();
|
StringBuilder resultTextBuilder = new StringBuilder();
|
||||||
|
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
int resultUserId = results.getInt("user");
|
int resultUserId = results.getInt("user");
|
||||||
int resultAction = results.getInt("action");
|
int resultAction = results.getInt("action");
|
||||||
int resultType = results.getInt("type");
|
int resultType = results.getInt("type");
|
||||||
@@ -86,118 +101,140 @@ public class BlockLookup {
|
|||||||
int resultRolledBack = results.getInt("rolled_back");
|
int resultRolledBack = results.getInt("rolled_back");
|
||||||
|
|
||||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||||
|
|
||||||
UserStatement.loadName(statement.getConnection(), resultUserId);
|
UserStatement.loadName(statement.getConnection(), resultUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||||
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
resultTextBuilder =
|
|
||||||
new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + "CoreProtect " + Color.WHITE
|
resultTextBuilder = new StringBuilder(
|
||||||
+ "----- " + Util.getCoordinates(command, worldId, x, y, z, false, false) + "\n");
|
Color.WHITE + "----- " + Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "----- "
|
||||||
|
+ Util.getCoordinates(command, worldId, x, y, z, false, false) + "\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
Phrase phrase = Phrase.LOOKUP_BLOCK;
|
Phrase phrase = Phrase.LOOKUP_BLOCK;
|
||||||
String selector = Selector.FIRST;
|
String selector = Selector.FIRST;
|
||||||
String tag = Color.WHITE + "-";
|
String tag = Color.WHITE + "-";
|
||||||
if (resultAction == 2 || resultAction == 3) {
|
if (resultAction == 2 || resultAction == 3) {
|
||||||
|
|
||||||
phrase = Phrase.LOOKUP_INTERACTION; // {clicked|killed}
|
phrase = Phrase.LOOKUP_INTERACTION; // {clicked|killed}
|
||||||
selector = (resultAction != 3 ? Selector.FIRST : Selector.SECOND);
|
selector = (resultAction != 3 ? Selector.FIRST : Selector.SECOND);
|
||||||
tag = (resultAction != 3 ? Color.WHITE + "-" : Color.RED + "-");
|
tag = (resultAction != 3 ? Color.WHITE + "-" : Color.RED + "-");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
phrase = Phrase.LOOKUP_BLOCK; // {placed|broke}
|
phrase = Phrase.LOOKUP_BLOCK; // {placed|broke}
|
||||||
selector = (resultAction != 0 ? Selector.FIRST : Selector.SECOND);
|
selector = (resultAction != 0 ? Selector.FIRST : Selector.SECOND);
|
||||||
tag = (resultAction != 0 ? Color.GREEN + "+" : Color.RED + "-");
|
tag = (resultAction != 0 ? Color.GREEN + "+" : Color.RED + "-");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String rbFormat = "";
|
String rbFormat = "";
|
||||||
if (resultRolledBack == 1 || resultRolledBack == 3) {
|
if (resultRolledBack == 1 || resultRolledBack == 3) {
|
||||||
|
|
||||||
rbFormat = Color.STRIKETHROUGH;
|
rbFormat = Color.STRIKETHROUGH;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String target;
|
String target;
|
||||||
if (resultAction == 3) {
|
if (resultAction == 3) {
|
||||||
|
|
||||||
target = Util.getEntityType(resultType).name();
|
target = Util.getEntityType(resultType).name();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Material resultMaterial = Util.getType(resultType);
|
Material resultMaterial = Util.getType(resultType);
|
||||||
if (resultMaterial == null) {
|
if (resultMaterial == null) {
|
||||||
|
|
||||||
resultMaterial = Material.AIR;
|
resultMaterial = Material.AIR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target = Util.nameFilter(resultMaterial.name().toLowerCase(Locale.ROOT), resultData);
|
target = Util.nameFilter(resultMaterial.name().toLowerCase(Locale.ROOT), resultData);
|
||||||
target = "minecraft:" + target.toLowerCase(Locale.ROOT);
|
target = "minecraft:" + target.toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.length() > 0) {
|
if (target.length() > 0) {
|
||||||
|
|
||||||
target = "" + target + "";
|
target = "" + target + "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide "minecraft:" for now.
|
// Hide "minecraft:" for now.
|
||||||
if (target.startsWith("minecraft:")) {
|
if (target.startsWith("minecraft:")) {
|
||||||
|
|
||||||
target = target.split(":")[1];
|
target = target.split(":")[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultTextBuilder
|
resultTextBuilder.append(timeAgo + " " + tag + " ")
|
||||||
.append(timeAgo + " " + tag + " ")
|
.append(Phrase.build(phrase, Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat,
|
||||||
.append(Phrase.build(
|
Color.DARK_AQUA + rbFormat + target + Color.WHITE, selector))
|
||||||
phrase,
|
|
||||||
Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat,
|
|
||||||
Color.DARK_AQUA + rbFormat + target + Color.WHITE,
|
|
||||||
selector))
|
|
||||||
.append("\n");
|
.append("\n");
|
||||||
PluginChannelListener.getInstance()
|
PluginChannelListener.getInstance().sendData(commandSender, resultTime, phrase, selector, resultUser,
|
||||||
.sendData(
|
target, -1, x, y, z, worldId, rbFormat, false, tag.contains("+"));
|
||||||
commandSender,
|
|
||||||
resultTime,
|
|
||||||
phrase,
|
|
||||||
selector,
|
|
||||||
resultUser,
|
|
||||||
target,
|
|
||||||
-1,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
z,
|
|
||||||
worldId,
|
|
||||||
rbFormat,
|
|
||||||
false,
|
|
||||||
tag.contains("+"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultText = resultTextBuilder.toString();
|
resultText = resultTextBuilder.toString();
|
||||||
results.close();
|
results.close();
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
|
|
||||||
if (count > limit) {
|
if (count > limit) {
|
||||||
|
|
||||||
String pageInfo = Color.WHITE + "-----\n";
|
String pageInfo = Color.WHITE + "-----\n";
|
||||||
pageInfo = pageInfo + Util.getPageNavigation(command, page, totalPages) + "\n";
|
pageInfo = pageInfo + Util.getPageNavigation(command, page, totalPages) + "\n";
|
||||||
resultText = resultText + pageInfo;
|
resultText = resultText + pageInfo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (rowMax > count && count > 0) {
|
if (rowMax > count && count > 0) {
|
||||||
|
|
||||||
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND);
|
+ Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Color.WHITE + "No block data
|
|
||||||
|
// resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " +
|
||||||
|
// Color.WHITE + "No block data
|
||||||
// found at " + Color.ITALIC + "x" + x + "/y" + y + "/z" + z + ".";
|
// found at " + Color.ITALIC + "x" + x + "/y" + y + "/z" + z + ".";
|
||||||
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(Phrase.NO_DATA_LOCATION, Selector.FIRST);
|
+ Phrase.build(Phrase.NO_DATA_LOCATION, Selector.FIRST);
|
||||||
if (!blockName.equals("air") && !blockName.equals("cave_air")) {
|
if (!blockName.equals("air") && !blockName.equals("cave_air")) {
|
||||||
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(
|
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(
|
||||||
Phrase.NO_DATA,
|
Phrase.NO_DATA, Color.ITALIC + block.getType().name().toLowerCase(Locale.ROOT)) + "\n";
|
||||||
Color.ITALIC + block.getType().name().toLowerCase(Locale.ROOT))
|
|
||||||
+ "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.lookupPage.put(commandSender.getName(), page);
|
ConfigHandler.lookupPage.put(commandSender.getName(), page);
|
||||||
ConfigHandler.lookupType.put(commandSender.getName(), 2);
|
ConfigHandler.lookupType.put(commandSender.getName(), 2);
|
||||||
ConfigHandler.lookupCommand.put(
|
ConfigHandler.lookupCommand.put(commandSender.getName(),
|
||||||
commandSender.getName(), x + "." + y + "." + z + "." + worldId + ".0." + limit);
|
x + "." + y + "." + z + "." + worldId + ".0." + limit);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultText;
|
return resultText;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,31 +18,40 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
public class ChestTransactionLookup {
|
public class ChestTransactionLookup {
|
||||||
|
|
||||||
public static List<String> performLookup(
|
public static List<String> performLookup(String command, Statement statement, Location l,
|
||||||
String command,
|
CommandSender commandSender, int page, int limit, boolean exact)
|
||||||
Statement statement,
|
{
|
||||||
Location l,
|
|
||||||
CommandSender commandSender,
|
|
||||||
int page,
|
|
||||||
int limit,
|
|
||||||
boolean exact) {
|
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (l == null) {
|
if (l == null) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
|
|
||||||
if (commandSender.hasPermission("coreprotect.co")) {
|
if (commandSender.hasPermission("coreprotect.co")) {
|
||||||
|
|
||||||
command = "co";
|
command = "co";
|
||||||
|
|
||||||
} else if (commandSender.hasPermission("coreprotect.core")) {
|
} else if (commandSender.hasPermission("coreprotect.core")) {
|
||||||
|
|
||||||
command = "core";
|
command = "core";
|
||||||
|
|
||||||
} else if (commandSender.hasPermission("coreprotect.coreprotect")) {
|
} else if (commandSender.hasPermission("coreprotect.coreprotect")) {
|
||||||
|
|
||||||
command = "coreprotect";
|
command = "coreprotect";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
command = "co";
|
command = "co";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@@ -62,15 +71,21 @@ public class ChestTransactionLookup {
|
|||||||
+ Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + x + "' OR x = '" + x2
|
+ Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + x + "' OR x = '" + x2
|
||||||
+ "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y + "' LIMIT 0, 1";
|
+ "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y + "' LIMIT 0, 1";
|
||||||
if (exact) {
|
if (exact) {
|
||||||
|
|
||||||
query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "container "
|
query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "container "
|
||||||
+ Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + l.getBlockX()
|
+ Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + l.getBlockX()
|
||||||
+ "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y + "' LIMIT 0, 1";
|
+ "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y + "' LIMIT 0, 1";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSet results = statement.executeQuery(query);
|
ResultSet results = statement.executeQuery(query);
|
||||||
|
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
count = results.getInt("count");
|
count = results.getInt("count");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.close();
|
results.close();
|
||||||
|
|
||||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||||
@@ -80,13 +95,17 @@ public class ChestTransactionLookup {
|
|||||||
+ "' OR x = '" + x2 + "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y
|
+ "' OR x = '" + x2 + "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y
|
||||||
+ "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
+ "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||||
if (exact) {
|
if (exact) {
|
||||||
|
|
||||||
query = "SELECT time,user,action,type,data,amount,metadata,rolled_back FROM " + ConfigHandler.prefix
|
query = "SELECT time,user,action,type,data,amount,metadata,rolled_back FROM " + ConfigHandler.prefix
|
||||||
+ "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '"
|
+ "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '"
|
||||||
+ l.getBlockX() + "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y
|
+ l.getBlockX() + "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y
|
||||||
+ "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
+ "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results = statement.executeQuery(query);
|
results = statement.executeQuery(query);
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
int resultUserId = results.getInt("user");
|
int resultUserId = results.getInt("user");
|
||||||
int resultAction = results.getInt("action");
|
int resultAction = results.getInt("action");
|
||||||
int resultType = results.getInt("type");
|
int resultType = results.getInt("type");
|
||||||
@@ -98,93 +117,105 @@ public class ChestTransactionLookup {
|
|||||||
String tooltip = Util.getEnchantments(resultMetadata, resultType, resultAmount);
|
String tooltip = Util.getEnchantments(resultMetadata, resultType, resultAmount);
|
||||||
|
|
||||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||||
|
|
||||||
UserStatement.loadName(statement.getConnection(), resultUserId);
|
UserStatement.loadName(statement.getConnection(), resultUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||||
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
|
||||||
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA
|
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA
|
||||||
+ Phrase.build(Phrase.CONTAINER_HEADER) + Color.WHITE + " ----- "
|
+ Phrase.build(Phrase.CONTAINER_HEADER) + Color.WHITE + " ----- "
|
||||||
+ Util.getCoordinates(command, worldId, x, y, z, false, false))
|
+ Util.getCoordinates(command, worldId, x, y, z, false, false)).toString());
|
||||||
.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
String selector = (resultAction != 0 ? Selector.FIRST : Selector.SECOND);
|
String selector = (resultAction != 0 ? Selector.FIRST : Selector.SECOND);
|
||||||
String tag = (resultAction != 0 ? Color.GREEN + "+" : Color.RED + "-");
|
String tag = (resultAction != 0 ? Color.GREEN + "+" : Color.RED + "-");
|
||||||
String rbFormat = "";
|
String rbFormat = "";
|
||||||
if (resultRolledBack == 1 || resultRolledBack == 3) {
|
if (resultRolledBack == 1 || resultRolledBack == 3) {
|
||||||
|
|
||||||
rbFormat = Color.STRIKETHROUGH;
|
rbFormat = Color.STRIKETHROUGH;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Material resultMaterial = Util.getType(resultType);
|
Material resultMaterial = Util.getType(resultType);
|
||||||
if (resultMaterial == null) {
|
if (resultMaterial == null) {
|
||||||
|
|
||||||
resultMaterial = Material.AIR;
|
resultMaterial = Material.AIR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String target = resultMaterial.name().toLowerCase(Locale.ROOT);
|
String target = resultMaterial.name().toLowerCase(Locale.ROOT);
|
||||||
target = Util.nameFilter(target, resultData);
|
target = Util.nameFilter(target, resultData);
|
||||||
if (target.length() > 0) {
|
if (target.length() > 0) {
|
||||||
|
|
||||||
target = "minecraft:" + target.toLowerCase(Locale.ROOT) + "";
|
target = "minecraft:" + target.toLowerCase(Locale.ROOT) + "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide "minecraft:" for now.
|
// Hide "minecraft:" for now.
|
||||||
if (target.startsWith("minecraft:")) {
|
if (target.startsWith("minecraft:")) {
|
||||||
|
|
||||||
target = target.split(":")[1];
|
target = target.split(":")[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.add(new StringBuilder(timeAgo + " " + tag + " "
|
result.add(new StringBuilder(timeAgo + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER,
|
||||||
+ Phrase.build(
|
Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat, "x" + resultAmount,
|
||||||
Phrase.LOOKUP_CONTAINER,
|
Util.createTooltip(Color.DARK_AQUA + rbFormat + target, tooltip) + Color.WHITE, selector))
|
||||||
Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat,
|
|
||||||
"x" + resultAmount,
|
|
||||||
Util.createTooltip(Color.DARK_AQUA + rbFormat + target, tooltip) + Color.WHITE,
|
|
||||||
selector))
|
|
||||||
.toString());
|
.toString());
|
||||||
PluginChannelListener.getInstance()
|
PluginChannelListener.getInstance().sendData(commandSender, resultTime, Phrase.LOOKUP_CONTAINER,
|
||||||
.sendData(
|
selector, resultUser, target, resultAmount, x, y, z, worldId, rbFormat, true,
|
||||||
commandSender,
|
tag.contains("+"));
|
||||||
resultTime,
|
|
||||||
Phrase.LOOKUP_CONTAINER,
|
|
||||||
selector,
|
|
||||||
resultUser,
|
|
||||||
target,
|
|
||||||
resultAmount,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
z,
|
|
||||||
worldId,
|
|
||||||
rbFormat,
|
|
||||||
true,
|
|
||||||
tag.contains("+"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.close();
|
results.close();
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
|
|
||||||
if (count > limit) {
|
if (count > limit) {
|
||||||
|
|
||||||
result.add(Color.WHITE + "-----");
|
result.add(Color.WHITE + "-----");
|
||||||
result.add(Util.getPageNavigation(command, page, totalPages));
|
result.add(Util.getPageNavigation(command, page, totalPages));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (rowMax > count && count > 0) {
|
if (rowMax > count && count > 0) {
|
||||||
|
|
||||||
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND));
|
+ Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(Phrase.NO_DATA_LOCATION, Selector.SECOND));
|
+ Phrase.build(Phrase.NO_DATA_LOCATION, Selector.SECOND));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.lookupType.put(commandSender.getName(), 1);
|
ConfigHandler.lookupType.put(commandSender.getName(), 1);
|
||||||
ConfigHandler.lookupPage.put(commandSender.getName(), page);
|
ConfigHandler.lookupPage.put(commandSender.getName(), page);
|
||||||
ConfigHandler.lookupCommand.put(
|
ConfigHandler.lookupCommand.put(commandSender.getName(),
|
||||||
commandSender.getName(),
|
|
||||||
x + "." + y + "." + z + "." + worldId + "." + x2 + "." + y2 + "." + z2 + "." + limit);
|
x + "." + y + "." + z + "." + worldId + "." + x2 + "." + y2 + "." + z2 + "." + limit);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,31 +16,40 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
public class InteractionLookup {
|
public class InteractionLookup {
|
||||||
|
|
||||||
public static String performLookup(
|
public static String performLookup(String command, Statement statement, Block block, CommandSender commandSender,
|
||||||
String command,
|
int offset, int page, int limit)
|
||||||
Statement statement,
|
{
|
||||||
Block block,
|
|
||||||
CommandSender commandSender,
|
|
||||||
int offset,
|
|
||||||
int page,
|
|
||||||
int limit) {
|
|
||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
|
|
||||||
if (commandSender.hasPermission("coreprotect.co")) {
|
if (commandSender.hasPermission("coreprotect.co")) {
|
||||||
|
|
||||||
command = "co";
|
command = "co";
|
||||||
|
|
||||||
} else if (commandSender.hasPermission("coreprotect.core")) {
|
} else if (commandSender.hasPermission("coreprotect.core")) {
|
||||||
|
|
||||||
command = "core";
|
command = "core";
|
||||||
|
|
||||||
} else if (commandSender.hasPermission("coreprotect.coreprotect")) {
|
} else if (commandSender.hasPermission("coreprotect.coreprotect")) {
|
||||||
|
|
||||||
command = "coreprotect";
|
command = "coreprotect";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
command = "co";
|
command = "co";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@@ -54,7 +63,9 @@ public class InteractionLookup {
|
|||||||
int rowMax = page * limit;
|
int rowMax = page * limit;
|
||||||
int pageStart = rowMax - limit;
|
int pageStart = rowMax - limit;
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
|
|
||||||
checkTime = time - offset;
|
checkTime = time - offset;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "block "
|
String query = "SELECT COUNT(*) as count from " + ConfigHandler.prefix + "block "
|
||||||
@@ -63,8 +74,11 @@ public class InteractionLookup {
|
|||||||
ResultSet results = statement.executeQuery(query);
|
ResultSet results = statement.executeQuery(query);
|
||||||
|
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
count = results.getInt("count");
|
count = results.getInt("count");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.close();
|
results.close();
|
||||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||||
|
|
||||||
@@ -76,6 +90,7 @@ public class InteractionLookup {
|
|||||||
|
|
||||||
StringBuilder resultBuilder = new StringBuilder();
|
StringBuilder resultBuilder = new StringBuilder();
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
int resultUserId = results.getInt("user");
|
int resultUserId = results.getInt("user");
|
||||||
int resultAction = results.getInt("action");
|
int resultAction = results.getInt("action");
|
||||||
int resultType = results.getInt("type");
|
int resultType = results.getInt("type");
|
||||||
@@ -84,91 +99,105 @@ public class InteractionLookup {
|
|||||||
int resultRolledBack = results.getInt("rolled_back");
|
int resultRolledBack = results.getInt("rolled_back");
|
||||||
|
|
||||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||||
|
|
||||||
UserStatement.loadName(statement.getConnection(), resultUserId);
|
UserStatement.loadName(statement.getConnection(), resultUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||||
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
|
||||||
resultBuilder = new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA
|
resultBuilder = new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA
|
||||||
+ Phrase.build(Phrase.INTERACTIONS_HEADER) + Color.WHITE + " ----- "
|
+ Phrase.build(Phrase.INTERACTIONS_HEADER) + Color.WHITE + " ----- "
|
||||||
+ Util.getCoordinates(command, worldId, x, y, z, false, false) + "\n");
|
+ Util.getCoordinates(command, worldId, x, y, z, false, false) + "\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
String rbFormat = "";
|
String rbFormat = "";
|
||||||
if (resultRolledBack == 1 || resultRolledBack == 3) {
|
if (resultRolledBack == 1 || resultRolledBack == 3) {
|
||||||
|
|
||||||
rbFormat = Color.STRIKETHROUGH;
|
rbFormat = Color.STRIKETHROUGH;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Material resultMaterial = Util.getType(resultType);
|
Material resultMaterial = Util.getType(resultType);
|
||||||
if (resultMaterial == null) {
|
if (resultMaterial == null) {
|
||||||
|
|
||||||
resultMaterial = Material.AIR;
|
resultMaterial = Material.AIR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String target = resultMaterial.name().toLowerCase(Locale.ROOT);
|
String target = resultMaterial.name().toLowerCase(Locale.ROOT);
|
||||||
target = Util.nameFilter(target, resultData);
|
target = Util.nameFilter(target, resultData);
|
||||||
if (target.length() > 0) {
|
if (target.length() > 0) {
|
||||||
|
|
||||||
target = "minecraft:" + target.toLowerCase(Locale.ROOT) + "";
|
target = "minecraft:" + target.toLowerCase(Locale.ROOT) + "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide "minecraft:" for now.
|
// Hide "minecraft:" for now.
|
||||||
if (target.startsWith("minecraft:")) {
|
if (target.startsWith("minecraft:")) {
|
||||||
|
|
||||||
target = target.split(":")[1];
|
target = target.split(":")[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultBuilder
|
resultBuilder.append(timeAgo + " " + Color.WHITE + "- ")
|
||||||
.append(timeAgo + " " + Color.WHITE + "- ")
|
.append(Phrase.build(Phrase.LOOKUP_INTERACTION,
|
||||||
.append(Phrase.build(
|
|
||||||
Phrase.LOOKUP_INTERACTION,
|
|
||||||
Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat,
|
Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat,
|
||||||
Color.DARK_AQUA + rbFormat + target + Color.WHITE,
|
Color.DARK_AQUA + rbFormat + target + Color.WHITE, Selector.FIRST))
|
||||||
Selector.FIRST))
|
|
||||||
.append("\n");
|
.append("\n");
|
||||||
PluginChannelListener.getInstance()
|
PluginChannelListener.getInstance().sendData(commandSender, resultTime, Phrase.LOOKUP_INTERACTION,
|
||||||
.sendData(
|
Selector.FIRST, resultUser, target, -1, x, y, z, worldId, rbFormat, false, false);
|
||||||
commandSender,
|
|
||||||
resultTime,
|
|
||||||
Phrase.LOOKUP_INTERACTION,
|
|
||||||
Selector.FIRST,
|
|
||||||
resultUser,
|
|
||||||
target,
|
|
||||||
-1,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
z,
|
|
||||||
worldId,
|
|
||||||
rbFormat,
|
|
||||||
false,
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = resultBuilder.toString();
|
result = resultBuilder.toString();
|
||||||
results.close();
|
results.close();
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
|
|
||||||
if (count > limit) {
|
if (count > limit) {
|
||||||
|
|
||||||
String pageInfo = Color.WHITE + "-----\n";
|
String pageInfo = Color.WHITE + "-----\n";
|
||||||
pageInfo = pageInfo + Util.getPageNavigation(command, page, totalPages) + "\n";
|
pageInfo = pageInfo + Util.getPageNavigation(command, page, totalPages) + "\n";
|
||||||
result = result + pageInfo;
|
result = result + pageInfo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (rowMax > count && count > 0) {
|
if (rowMax > count && count > 0) {
|
||||||
|
|
||||||
result = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
result = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND);
|
+ Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
result = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
result = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(Phrase.NO_DATA_LOCATION, Selector.THIRD);
|
+ Phrase.build(Phrase.NO_DATA_LOCATION, Selector.THIRD);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.lookupPage.put(commandSender.getName(), page);
|
ConfigHandler.lookupPage.put(commandSender.getName(), page);
|
||||||
ConfigHandler.lookupType.put(commandSender.getName(), 7);
|
ConfigHandler.lookupType.put(commandSender.getName(), 7);
|
||||||
ConfigHandler.lookupCommand.put(
|
ConfigHandler.lookupCommand.put(commandSender.getName(),
|
||||||
commandSender.getName(), x + "." + y + "." + z + "." + worldId + ".2." + limit);
|
x + "." + y + "." + z + "." + worldId + ".2." + limit);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,17 +10,23 @@ import net.coreprotect.config.ConfigHandler;
|
|||||||
public class PlayerLookup {
|
public class PlayerLookup {
|
||||||
|
|
||||||
public static boolean playerExists(Connection connection, String user) {
|
public static boolean playerExists(Connection connection, String user) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
int id = -1;
|
int id = -1;
|
||||||
String uuid = null;
|
String uuid = null;
|
||||||
|
|
||||||
if (ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT)) != null) {
|
if (ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String collate = "";
|
String collate = "";
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
collate = " COLLATE NOCASE";
|
collate = " COLLATE NOCASE";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String query = "SELECT rowid as id, uuid FROM " + ConfigHandler.prefix + "user WHERE user = ?" + collate
|
String query = "SELECT rowid as id, uuid FROM " + ConfigHandler.prefix + "user WHERE user = ?" + collate
|
||||||
@@ -31,26 +37,38 @@ public class PlayerLookup {
|
|||||||
ResultSet results = preparedStmt.executeQuery();
|
ResultSet results = preparedStmt.executeQuery();
|
||||||
|
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
id = results.getInt("id");
|
id = results.getInt("id");
|
||||||
uuid = results.getString("uuid");
|
uuid = results.getString("uuid");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.close();
|
results.close();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
if (id > -1) {
|
if (id > -1) {
|
||||||
|
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
|
|
||||||
ConfigHandler.uuidCache.put(user.toLowerCase(Locale.ROOT), uuid);
|
ConfigHandler.uuidCache.put(user.toLowerCase(Locale.ROOT), uuid);
|
||||||
ConfigHandler.uuidCacheReversed.put(uuid, user);
|
ConfigHandler.uuidCacheReversed.put(uuid, user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.playerIdCache.put(user.toLowerCase(Locale.ROOT), id);
|
ConfigHandler.playerIdCache.put(user.toLowerCase(Locale.ROOT), id);
|
||||||
ConfigHandler.playerIdCacheReversed.put(id, user);
|
ConfigHandler.playerIdCacheReversed.put(id, user);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,25 +20,40 @@ public class SignMessageLookup {
|
|||||||
|
|
||||||
static Pattern pattern = Pattern.compile("§x(§[a-fA-F0-9]){6}");
|
static Pattern pattern = Pattern.compile("§x(§[a-fA-F0-9]){6}");
|
||||||
|
|
||||||
public static List<String> performLookup(
|
public static List<String> performLookup(String command, Statement statement, Location l,
|
||||||
String command, Statement statement, Location l, CommandSender commandSender, int page, int limit) {
|
CommandSender commandSender, int page, int limit)
|
||||||
|
{
|
||||||
|
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (l == null) {
|
if (l == null) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
|
|
||||||
if (commandSender.hasPermission("coreprotect.co")) {
|
if (commandSender.hasPermission("coreprotect.co")) {
|
||||||
|
|
||||||
command = "co";
|
command = "co";
|
||||||
|
|
||||||
} else if (commandSender.hasPermission("coreprotect.core")) {
|
} else if (commandSender.hasPermission("coreprotect.core")) {
|
||||||
|
|
||||||
command = "core";
|
command = "core";
|
||||||
|
|
||||||
} else if (commandSender.hasPermission("coreprotect.coreprotect")) {
|
} else if (commandSender.hasPermission("coreprotect.coreprotect")) {
|
||||||
|
|
||||||
command = "coreprotect";
|
command = "coreprotect";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
command = "co";
|
command = "co";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@@ -57,8 +72,11 @@ public class SignMessageLookup {
|
|||||||
ResultSet results = statement.executeQuery(query);
|
ResultSet results = statement.executeQuery(query);
|
||||||
|
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
count = results.getInt("count");
|
count = results.getInt("count");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.close();
|
results.close();
|
||||||
|
|
||||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||||
@@ -71,6 +89,7 @@ public class SignMessageLookup {
|
|||||||
results = statement.executeQuery(query);
|
results = statement.executeQuery(query);
|
||||||
|
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
|
|
||||||
long resultTime = results.getLong("time");
|
long resultTime = results.getLong("time");
|
||||||
int resultUserId = results.getInt("user");
|
int resultUserId = results.getInt("user");
|
||||||
String line1 = results.getString("line_1");
|
String line1 = results.getString("line_1");
|
||||||
@@ -85,109 +104,173 @@ public class SignMessageLookup {
|
|||||||
|
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
if (isFront && line1 != null && line1.length() > 0) {
|
if (isFront && line1 != null && line1.length() > 0) {
|
||||||
|
|
||||||
message.append(line1);
|
message.append(line1);
|
||||||
if (!line1.endsWith(" ")) {
|
if (!line1.endsWith(" ")) {
|
||||||
|
|
||||||
message.append(" ");
|
message.append(" ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFront && line2 != null && line2.length() > 0) {
|
if (isFront && line2 != null && line2.length() > 0) {
|
||||||
|
|
||||||
message.append(line2);
|
message.append(line2);
|
||||||
if (!line2.endsWith(" ")) {
|
if (!line2.endsWith(" ")) {
|
||||||
|
|
||||||
message.append(" ");
|
message.append(" ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFront && line3 != null && line3.length() > 0) {
|
if (isFront && line3 != null && line3.length() > 0) {
|
||||||
|
|
||||||
message.append(line3);
|
message.append(line3);
|
||||||
if (!line3.endsWith(" ")) {
|
if (!line3.endsWith(" ")) {
|
||||||
|
|
||||||
message.append(" ");
|
message.append(" ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFront && line4 != null && line4.length() > 0) {
|
if (isFront && line4 != null && line4.length() > 0) {
|
||||||
|
|
||||||
message.append(line4);
|
message.append(line4);
|
||||||
if (!line4.endsWith(" ")) {
|
if (!line4.endsWith(" ")) {
|
||||||
|
|
||||||
message.append(" ");
|
message.append(" ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFront && line5 != null && line5.length() > 0) {
|
if (!isFront && line5 != null && line5.length() > 0) {
|
||||||
|
|
||||||
message.append(line5);
|
message.append(line5);
|
||||||
if (!line5.endsWith(" ")) {
|
if (!line5.endsWith(" ")) {
|
||||||
|
|
||||||
message.append(" ");
|
message.append(" ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFront && line6 != null && line6.length() > 0) {
|
if (!isFront && line6 != null && line6.length() > 0) {
|
||||||
|
|
||||||
message.append(line6);
|
message.append(line6);
|
||||||
if (!line6.endsWith(" ")) {
|
if (!line6.endsWith(" ")) {
|
||||||
|
|
||||||
message.append(" ");
|
message.append(" ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFront && line7 != null && line7.length() > 0) {
|
if (!isFront && line7 != null && line7.length() > 0) {
|
||||||
|
|
||||||
message.append(line7);
|
message.append(line7);
|
||||||
if (!line7.endsWith(" ")) {
|
if (!line7.endsWith(" ")) {
|
||||||
|
|
||||||
message.append(" ");
|
message.append(" ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFront && line8 != null && line8.length() > 0) {
|
if (!isFront && line8 != null && line8.length() > 0) {
|
||||||
|
|
||||||
message.append(line8);
|
message.append(line8);
|
||||||
if (!line8.endsWith(" ")) {
|
if (!line8.endsWith(" ")) {
|
||||||
|
|
||||||
message.append(" ");
|
message.append(" ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String parsedMessage = message.toString();
|
String parsedMessage = message.toString();
|
||||||
if (parsedMessage.contains("§x")) {
|
if (parsedMessage.contains("§x")) {
|
||||||
for (Matcher matcher = pattern.matcher(parsedMessage);
|
|
||||||
matcher.find();
|
for (Matcher matcher = pattern.matcher(parsedMessage); matcher
|
||||||
matcher = pattern.matcher(parsedMessage)) {
|
.find(); matcher = pattern.matcher(parsedMessage))
|
||||||
|
{
|
||||||
|
|
||||||
String color = parsedMessage.substring(matcher.start(), matcher.end());
|
String color = parsedMessage.substring(matcher.start(), matcher.end());
|
||||||
parsedMessage = parsedMessage.replace(color, "");
|
parsedMessage = parsedMessage.replace(color, "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||||
|
|
||||||
UserStatement.loadName(statement.getConnection(), resultUserId);
|
UserStatement.loadName(statement.getConnection(), resultUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
String resultUser = ConfigHandler.playerIdCacheReversed.get(resultUserId);
|
||||||
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA
|
|
||||||
+ Phrase.build(Phrase.SIGN_HEADER) + Color.WHITE + " ----- "
|
result.add(new StringBuilder(
|
||||||
+ Util.getCoordinates(command, worldId, x, y, z, false, false) + "")
|
Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.SIGN_HEADER) + Color.WHITE
|
||||||
|
+ " ----- " + Util.getCoordinates(command, worldId, x, y, z, false, false) + "")
|
||||||
.toString());
|
.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
result.add(timeAgo + Color.WHITE + " - " + Color.DARK_AQUA + resultUser + ": " + Color.WHITE + "\n"
|
result.add(timeAgo + Color.WHITE + " - " + Color.DARK_AQUA + resultUser + ": " + Color.WHITE + "\n"
|
||||||
+ parsedMessage + Color.WHITE);
|
+ parsedMessage + Color.WHITE);
|
||||||
PluginChannelListener.getInstance()
|
PluginChannelListener.getInstance().sendMessageData(commandSender, resultTime, resultUser,
|
||||||
.sendMessageData(
|
message.toString(), true, x, y, z, worldId);
|
||||||
commandSender, resultTime, resultUser, message.toString(), true, x, y, z, worldId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.close();
|
results.close();
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
|
|
||||||
if (count > limit) {
|
if (count > limit) {
|
||||||
|
|
||||||
result.add(Color.WHITE + "-----");
|
result.add(Color.WHITE + "-----");
|
||||||
result.add(Util.getPageNavigation(command, page, totalPages));
|
result.add(Util.getPageNavigation(command, page, totalPages));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (rowMax > count && count > 0) {
|
if (rowMax > count && count > 0) {
|
||||||
|
|
||||||
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND));
|
+ Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(Phrase.NO_DATA_LOCATION, Selector.FOURTH));
|
+ Phrase.build(Phrase.NO_DATA_LOCATION, Selector.FOURTH));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.lookupType.put(commandSender.getName(), 8);
|
ConfigHandler.lookupType.put(commandSender.getName(), 8);
|
||||||
ConfigHandler.lookupPage.put(commandSender.getName(), page);
|
ConfigHandler.lookupPage.put(commandSender.getName(), page);
|
||||||
ConfigHandler.lookupCommand.put(
|
ConfigHandler.lookupCommand.put(commandSender.getName(),
|
||||||
commandSender.getName(), x + "." + y + "." + z + "." + worldId + ".8." + limit);
|
x + "." + y + "." + z + "." + worldId + ".8." + limit);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -17,161 +17,164 @@ import org.bukkit.entity.EntityType;
|
|||||||
|
|
||||||
public class RollbackComplete {
|
public class RollbackComplete {
|
||||||
|
|
||||||
public static void output(
|
public static void output(CommandSender user, Location location, List<String> checkUsers, List<Object> restrictList,
|
||||||
CommandSender user,
|
Map<Object, Boolean> excludeList, List<String> excludeUserList, List<Integer> actionList, String timeString,
|
||||||
Location location,
|
Integer chunkCount, Double seconds, Integer itemCount, Integer blockCount, Integer entityCount,
|
||||||
List<String> checkUsers,
|
int rollbackType, Integer[] radius, boolean verbose, boolean restrictWorld, int preview)
|
||||||
List<Object> restrictList,
|
{
|
||||||
Map<Object, Boolean> excludeList,
|
|
||||||
List<String> excludeUserList,
|
|
||||||
List<Integer> actionList,
|
|
||||||
String timeString,
|
|
||||||
Integer chunkCount,
|
|
||||||
Double seconds,
|
|
||||||
Integer itemCount,
|
|
||||||
Integer blockCount,
|
|
||||||
Integer entityCount,
|
|
||||||
int rollbackType,
|
|
||||||
Integer[] radius,
|
|
||||||
boolean verbose,
|
|
||||||
boolean restrictWorld,
|
|
||||||
int preview) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (preview == 2) {
|
if (preview == 2) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PREVIEW_CANCELLED));
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PREVIEW_CANCELLED));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendMessage(user, "-----");
|
Chat.sendMessage(user, "-----");
|
||||||
|
|
||||||
StringBuilder usersBuilder = new StringBuilder();
|
StringBuilder usersBuilder = new StringBuilder();
|
||||||
for (String value : checkUsers) {
|
for (String value : checkUsers) {
|
||||||
|
|
||||||
if (usersBuilder.length() == 0) {
|
if (usersBuilder.length() == 0) {
|
||||||
|
|
||||||
usersBuilder = usersBuilder.append("" + value + "");
|
usersBuilder = usersBuilder.append("" + value + "");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
usersBuilder.append(", ").append(value);
|
usersBuilder.append(", ").append(value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String users = usersBuilder.toString();
|
String users = usersBuilder.toString();
|
||||||
|
|
||||||
if (users.equals("#global") && restrictWorld) {
|
if (users.equals("#global") && restrictWorld) {
|
||||||
|
|
||||||
users = "#" + location.getWorld().getName();
|
users = "#" + location.getWorld().getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preview > 0) {
|
if (preview > 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_COMPLETED, users, Selector.THIRD)); // preview
|
||||||
+ Phrase.build(Phrase.ROLLBACK_COMPLETED, users, Selector.THIRD)); // preview
|
|
||||||
} else if (rollbackType == 0) {
|
} else if (rollbackType == 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_COMPLETED, users, Selector.FIRST)); // rollback
|
||||||
+ Phrase.build(Phrase.ROLLBACK_COMPLETED, users, Selector.FIRST)); // rollback
|
|
||||||
} else if (rollbackType == 1) {
|
} else if (rollbackType == 1) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_COMPLETED, users, Selector.SECOND)); // restore
|
||||||
+ Phrase.build(Phrase.ROLLBACK_COMPLETED, users, Selector.SECOND)); // restore
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preview == 1 || rollbackType == 0 || rollbackType == 1) {
|
if (preview == 1 || rollbackType == 0 || rollbackType == 1) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_TIME, timeString));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_TIME, timeString));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radius != null) {
|
if (radius != null) {
|
||||||
|
|
||||||
int worldedit = radius[7];
|
int worldedit = radius[7];
|
||||||
if (worldedit == 0) {
|
if (worldedit == 0) {
|
||||||
|
|
||||||
Integer rollbackRadius = radius[0];
|
Integer rollbackRadius = radius[0];
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(user,
|
||||||
user,
|
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.ROLLBACK_RADIUS, rollbackRadius.toString(),
|
||||||
Phrase.ROLLBACK_RADIUS,
|
|
||||||
rollbackRadius.toString(),
|
|
||||||
(rollbackRadius == 1 ? Selector.FIRST : Selector.SECOND)));
|
(rollbackRadius == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_SELECTION, "#worldedit"));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_SELECTION, "#worldedit"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (restrictWorld && radius == null) {
|
if (restrictWorld && radius == null) {
|
||||||
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
.build(Phrase.ROLLBACK_WORLD_ACTION, location.getWorld().getName(), Selector.FIRST));
|
||||||
+ Phrase.build(
|
|
||||||
Phrase.ROLLBACK_WORLD_ACTION,
|
|
||||||
location.getWorld().getName(),
|
|
||||||
Selector.FIRST));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actionList.contains(4) && actionList.contains(11)) {
|
if (actionList.contains(4) && actionList.contains(11)) {
|
||||||
|
|
||||||
if (actionList.contains(0)) {
|
if (actionList.contains(0)) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "+inventory", Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "+inventory", Selector.SECOND));
|
|
||||||
} else if (actionList.contains(1)) {
|
} else if (actionList.contains(1)) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "-inventory", Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "-inventory", Selector.SECOND));
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "inventory", Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "inventory", Selector.SECOND));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (actionList.contains(4)) {
|
} else if (actionList.contains(4)) {
|
||||||
|
|
||||||
if (actionList.contains(0)) {
|
if (actionList.contains(0)) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "-container", Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "-container", Selector.SECOND));
|
|
||||||
} else if (actionList.contains(1)) {
|
} else if (actionList.contains(1)) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "+container", Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "+container", Selector.SECOND));
|
|
||||||
} else {
|
} else {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "container", Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "container", Selector.SECOND));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (actionList.contains(0) && actionList.contains(1)) {
|
} else if (actionList.contains(0) && actionList.contains(1)) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "block", Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "block", Selector.SECOND));
|
|
||||||
} else if (actionList.contains(0)) {
|
} else if (actionList.contains(0)) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "-block", Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "-block", Selector.SECOND));
|
|
||||||
} else if (actionList.contains(1)) {
|
} else if (actionList.contains(1)) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "+block", Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "+block", Selector.SECOND));
|
|
||||||
} else if (actionList.contains(3)) {
|
} else if (actionList.contains(3)) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "kill", Selector.SECOND));
|
||||||
+ Phrase.build(Phrase.ROLLBACK_WORLD_ACTION, "kill", Selector.SECOND));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (restrictList.size() > 0) {
|
if (restrictList.size() > 0) {
|
||||||
|
|
||||||
StringBuilder restrictTargets = new StringBuilder();
|
StringBuilder restrictTargets = new StringBuilder();
|
||||||
boolean material = false;
|
boolean material = false;
|
||||||
boolean item = false;
|
boolean item = false;
|
||||||
@@ -179,47 +182,60 @@ public class RollbackComplete {
|
|||||||
|
|
||||||
int targetCount = 0;
|
int targetCount = 0;
|
||||||
for (Object restrictTarget : restrictList) {
|
for (Object restrictTarget : restrictList) {
|
||||||
|
|
||||||
String targetName = "";
|
String targetName = "";
|
||||||
|
|
||||||
if (restrictTarget instanceof Material) {
|
if (restrictTarget instanceof Material) {
|
||||||
|
|
||||||
targetName = ((Material) restrictTarget).name().toLowerCase(Locale.ROOT);
|
targetName = ((Material) restrictTarget).name().toLowerCase(Locale.ROOT);
|
||||||
item = (!item ? !(((Material) restrictTarget).isBlock()) : item);
|
item = (!item ? !(((Material) restrictTarget).isBlock()) : item);
|
||||||
material = true;
|
material = true;
|
||||||
|
|
||||||
} else if (restrictTarget instanceof EntityType) {
|
} else if (restrictTarget instanceof EntityType) {
|
||||||
|
|
||||||
targetName = ((EntityType) restrictTarget).name().toLowerCase(Locale.ROOT);
|
targetName = ((EntityType) restrictTarget).name().toLowerCase(Locale.ROOT);
|
||||||
entity = true;
|
entity = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetCount == 0) {
|
if (targetCount == 0) {
|
||||||
|
|
||||||
restrictTargets = restrictTargets.append("" + targetName + "");
|
restrictTargets = restrictTargets.append("" + targetName + "");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
restrictTargets.append(", ").append(targetName);
|
restrictTargets.append(", ").append(targetName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
targetCount++;
|
targetCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String targetType = Selector.THIRD;
|
String targetType = Selector.THIRD;
|
||||||
if (material && !item && !entity) {
|
if (material && !item && !entity) {
|
||||||
|
|
||||||
targetType = Selector.FIRST;
|
targetType = Selector.FIRST;
|
||||||
|
|
||||||
} else if (material && item && !entity) {
|
} else if (material && item && !entity) {
|
||||||
|
|
||||||
targetType = Selector.THIRD;
|
targetType = Selector.THIRD;
|
||||||
|
|
||||||
} else if (entity && !material) {
|
} else if (entity && !material) {
|
||||||
|
|
||||||
targetType = Selector.SECOND;
|
targetType = Selector.SECOND;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(user,
|
||||||
user,
|
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.ROLLBACK_INCLUDE, restrictTargets.toString(), Selector.FIRST,
|
||||||
Phrase.ROLLBACK_INCLUDE,
|
targetType, (targetCount == 1 ? Selector.FIRST : Selector.SECOND))); // include
|
||||||
restrictTargets.toString(),
|
|
||||||
Selector.FIRST,
|
|
||||||
targetType,
|
|
||||||
(targetCount == 1 ? Selector.FIRST : Selector.SECOND))); // include
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excludeList.size() > 0) {
|
if (excludeList.size() > 0) {
|
||||||
|
|
||||||
StringBuilder excludeTargets = new StringBuilder();
|
StringBuilder excludeTargets = new StringBuilder();
|
||||||
boolean material = false;
|
boolean material = false;
|
||||||
boolean item = false;
|
boolean item = false;
|
||||||
@@ -227,192 +243,239 @@ public class RollbackComplete {
|
|||||||
|
|
||||||
int excludeCount = 0;
|
int excludeCount = 0;
|
||||||
for (Map.Entry<Object, Boolean> entry : excludeList.entrySet()) {
|
for (Map.Entry<Object, Boolean> entry : excludeList.entrySet()) {
|
||||||
|
|
||||||
Object excludeTarget = entry.getKey();
|
Object excludeTarget = entry.getKey();
|
||||||
Boolean excludeTargetInternal = entry.getValue();
|
Boolean excludeTargetInternal = entry.getValue();
|
||||||
|
|
||||||
// don't display default block excludes
|
// don't display default block excludes
|
||||||
if (Boolean.TRUE.equals(excludeTargetInternal)) {
|
if (Boolean.TRUE.equals(excludeTargetInternal)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't display that excluded water/fire/farmland in inventory rollbacks
|
// don't display that excluded water/fire/farmland in inventory rollbacks
|
||||||
if (actionList.contains(4) && actionList.contains(11)) {
|
if (actionList.contains(4) && actionList.contains(11)) {
|
||||||
if (excludeTarget.equals(Material.FIRE)
|
|
||||||
|| excludeTarget.equals(Material.WATER)
|
if (excludeTarget.equals(Material.FIRE) || excludeTarget.equals(Material.WATER)
|
||||||
|| excludeTarget.equals(Material.FARMLAND)) {
|
|| excludeTarget.equals(Material.FARMLAND))
|
||||||
|
{
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String targetName = "";
|
String targetName = "";
|
||||||
if (excludeTarget instanceof Material) {
|
if (excludeTarget instanceof Material) {
|
||||||
|
|
||||||
targetName = ((Material) excludeTarget).name().toLowerCase(Locale.ROOT);
|
targetName = ((Material) excludeTarget).name().toLowerCase(Locale.ROOT);
|
||||||
item = (!item ? !(((Material) excludeTarget).isBlock()) : item);
|
item = (!item ? !(((Material) excludeTarget).isBlock()) : item);
|
||||||
material = true;
|
material = true;
|
||||||
|
|
||||||
} else if (excludeTarget instanceof EntityType) {
|
} else if (excludeTarget instanceof EntityType) {
|
||||||
|
|
||||||
targetName = ((EntityType) excludeTarget).name().toLowerCase(Locale.ROOT);
|
targetName = ((EntityType) excludeTarget).name().toLowerCase(Locale.ROOT);
|
||||||
entity = true;
|
entity = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excludeCount == 0) {
|
if (excludeCount == 0) {
|
||||||
|
|
||||||
excludeTargets = excludeTargets.append("" + targetName + "");
|
excludeTargets = excludeTargets.append("" + targetName + "");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
excludeTargets.append(", ").append(targetName);
|
excludeTargets.append(", ").append(targetName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
excludeCount++;
|
excludeCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String targetType = Selector.THIRD;
|
String targetType = Selector.THIRD;
|
||||||
if (material && !item && !entity) {
|
if (material && !item && !entity) {
|
||||||
|
|
||||||
targetType = Selector.FIRST;
|
targetType = Selector.FIRST;
|
||||||
|
|
||||||
} else if (material && item && !entity) {
|
} else if (material && item && !entity) {
|
||||||
|
|
||||||
targetType = Selector.THIRD;
|
targetType = Selector.THIRD;
|
||||||
|
|
||||||
} else if (entity && !material) {
|
} else if (entity && !material) {
|
||||||
|
|
||||||
targetType = Selector.SECOND;
|
targetType = Selector.SECOND;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excludeCount > 0) {
|
if (excludeCount > 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.ROLLBACK_INCLUDE, excludeTargets.toString(), Selector.SECOND,
|
||||||
Phrase.ROLLBACK_INCLUDE,
|
targetType, (excludeCount == 1 ? Selector.FIRST : Selector.SECOND))); // exclude
|
||||||
excludeTargets.toString(),
|
|
||||||
Selector.SECOND,
|
|
||||||
targetType,
|
|
||||||
(excludeCount == 1 ? Selector.FIRST : Selector.SECOND))); // exclude
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excludeUserList.size() > 0) {
|
if (excludeUserList.size() > 0) {
|
||||||
|
|
||||||
StringBuilder excludeUsers = new StringBuilder();
|
StringBuilder excludeUsers = new StringBuilder();
|
||||||
|
|
||||||
int excludeCount = 0;
|
int excludeCount = 0;
|
||||||
for (String excludeUser : excludeUserList) {
|
for (String excludeUser : excludeUserList) {
|
||||||
|
|
||||||
// don't display that excluded #hopper in inventory rollbacks
|
// don't display that excluded #hopper in inventory rollbacks
|
||||||
if (actionList.contains(4) && actionList.contains(11)) {
|
if (actionList.contains(4) && actionList.contains(11)) {
|
||||||
|
|
||||||
if (excludeUser.equals("#hopper")) {
|
if (excludeUser.equals("#hopper")) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excludeCount == 0) {
|
if (excludeCount == 0) {
|
||||||
|
|
||||||
excludeUsers = excludeUsers.append("" + excludeUser + "");
|
excludeUsers = excludeUsers.append("" + excludeUser + "");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
excludeUsers.append(", ").append(excludeUser);
|
excludeUsers.append(", ").append(excludeUser);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
excludeCount++;
|
excludeCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excludeCount > 0) {
|
if (excludeCount > 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.ROLLBACK_EXCLUDED_USERS, excludeUsers.toString(),
|
||||||
Phrase.ROLLBACK_EXCLUDED_USERS,
|
|
||||||
excludeUsers.toString(),
|
|
||||||
(excludeCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
(excludeCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder modifiedData = new StringBuilder();
|
StringBuilder modifiedData = new StringBuilder();
|
||||||
Integer modifyCount = 0;
|
Integer modifyCount = 0;
|
||||||
if (actionList.contains(5)) {
|
if (actionList.contains(5)) {
|
||||||
modifiedData = modifiedData.append(Phrase.build(
|
|
||||||
Phrase.AMOUNT_ITEM,
|
modifiedData = modifiedData
|
||||||
NumberFormat.getInstance().format(blockCount),
|
.append(Phrase.build(Phrase.AMOUNT_ITEM, NumberFormat.getInstance().format(blockCount),
|
||||||
(blockCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
(blockCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
modifyCount++;
|
modifyCount++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (itemCount > 0 || actionList.contains(4)) {
|
if (itemCount > 0 || actionList.contains(4)) {
|
||||||
modifiedData = modifiedData.append(Phrase.build(
|
|
||||||
Phrase.AMOUNT_ITEM,
|
modifiedData = modifiedData
|
||||||
NumberFormat.getInstance().format(itemCount),
|
.append(Phrase.build(Phrase.AMOUNT_ITEM, NumberFormat.getInstance().format(itemCount),
|
||||||
(itemCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
(itemCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
modifyCount++;
|
modifyCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entityCount > 0) {
|
if (entityCount > 0) {
|
||||||
|
|
||||||
if (modifyCount > 0) {
|
if (modifyCount > 0) {
|
||||||
|
|
||||||
modifiedData.append(", ");
|
modifiedData.append(", ");
|
||||||
|
|
||||||
}
|
}
|
||||||
modifiedData.append(Phrase.build(
|
|
||||||
Phrase.AMOUNT_ENTITY,
|
modifiedData
|
||||||
NumberFormat.getInstance().format(entityCount),
|
.append(Phrase.build(Phrase.AMOUNT_ENTITY, NumberFormat.getInstance().format(entityCount),
|
||||||
(entityCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
(entityCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
modifyCount++;
|
modifyCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockCount > 0 || !actionList.contains(4) || preview > 0) {
|
if (blockCount > 0 || !actionList.contains(4) || preview > 0) {
|
||||||
|
|
||||||
if (modifyCount > 0) {
|
if (modifyCount > 0) {
|
||||||
|
|
||||||
modifiedData.append(", ");
|
modifiedData.append(", ");
|
||||||
|
|
||||||
}
|
}
|
||||||
modifiedData.append(Phrase.build(
|
|
||||||
Phrase.AMOUNT_BLOCK,
|
modifiedData.append(Phrase.build(Phrase.AMOUNT_BLOCK, NumberFormat.getInstance().format(blockCount),
|
||||||
NumberFormat.getInstance().format(blockCount),
|
|
||||||
(blockCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
(blockCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
modifyCount++;
|
modifyCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder modifiedDataVerbose = new StringBuilder();
|
StringBuilder modifiedDataVerbose = new StringBuilder();
|
||||||
if (verbose && preview == 0 && !actionList.contains(11)) {
|
if (verbose && preview == 0 && !actionList.contains(11)) {
|
||||||
|
|
||||||
if (chunkCount > -1 && modifyCount < 3) {
|
if (chunkCount > -1 && modifyCount < 3) {
|
||||||
|
|
||||||
if (modifyCount > 0) {
|
if (modifyCount > 0) {
|
||||||
|
|
||||||
modifiedData.append(", ");
|
modifiedData.append(", ");
|
||||||
|
|
||||||
}
|
}
|
||||||
modifiedData.append(Phrase.build(
|
|
||||||
Phrase.AMOUNT_CHUNK,
|
modifiedData.append(Phrase.build(Phrase.AMOUNT_CHUNK, NumberFormat.getInstance().format(chunkCount),
|
||||||
NumberFormat.getInstance().format(chunkCount),
|
|
||||||
(chunkCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
(chunkCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
modifyCount++;
|
modifyCount++;
|
||||||
|
|
||||||
} else if (chunkCount > 1) {
|
} else if (chunkCount > 1) {
|
||||||
modifiedDataVerbose.append(Phrase.build(
|
|
||||||
Phrase.AMOUNT_CHUNK,
|
modifiedDataVerbose
|
||||||
NumberFormat.getInstance().format(chunkCount),
|
.append(Phrase.build(Phrase.AMOUNT_CHUNK, NumberFormat.getInstance().format(chunkCount),
|
||||||
(chunkCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
(chunkCount == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(user,
|
||||||
user,
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_MODIFIED,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
modifiedData.toString(), (preview == 0 ? Selector.FIRST : Selector.SECOND)));
|
||||||
+ Phrase.build(
|
|
||||||
Phrase.ROLLBACK_MODIFIED,
|
|
||||||
modifiedData.toString(),
|
|
||||||
(preview == 0 ? Selector.FIRST : Selector.SECOND)));
|
|
||||||
if (modifiedDataVerbose.length() > 0) {
|
if (modifiedDataVerbose.length() > 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user,
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.ROLLBACK_MODIFIED,
|
||||||
+ Phrase.build(
|
modifiedDataVerbose.toString(), (preview == 0 ? Selector.FIRST : Selector.SECOND)));
|
||||||
Phrase.ROLLBACK_MODIFIED,
|
|
||||||
modifiedDataVerbose.toString(),
|
|
||||||
(preview == 0 ? Selector.FIRST : Selector.SECOND)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preview == 0) {
|
if (preview == 0) {
|
||||||
|
|
||||||
BigDecimal decimalSeconds = new BigDecimal(seconds).setScale(1, RoundingMode.HALF_EVEN);
|
BigDecimal decimalSeconds = new BigDecimal(seconds).setScale(1, RoundingMode.HALF_EVEN);
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(user,
|
||||||
user,
|
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
+ Phrase.build(
|
+ Phrase.build(Phrase.ROLLBACK_LENGTH,
|
||||||
Phrase.ROLLBACK_LENGTH,
|
|
||||||
decimalSeconds.stripTrailingZeros().toPlainString(),
|
decimalSeconds.stripTrailingZeros().toPlainString(),
|
||||||
(decimalSeconds.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND)));
|
(decimalSeconds.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendMessage(user, "-----");
|
Chat.sendMessage(user, "-----");
|
||||||
if (preview > 0) {
|
if (preview > 0) {
|
||||||
Chat.sendMessage(
|
|
||||||
user,
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
+ Phrase.build(Phrase.PLEASE_SELECT, "/co apply", "/co cancel"));
|
||||||
+ Phrase.build(Phrase.PLEASE_SELECT, "/co apply", "/co cancel"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,421 +36,646 @@ import org.bukkit.util.io.BukkitObjectInputStream;
|
|||||||
|
|
||||||
public class RollbackUtil extends Lookup {
|
public class RollbackUtil extends Lookup {
|
||||||
|
|
||||||
protected static int modifyContainerItems(
|
protected static int modifyContainerItems(Material type, Object container, int slot, ItemStack itemstack,
|
||||||
Material type, Object container, int slot, ItemStack itemstack, int action) {
|
int action)
|
||||||
|
{
|
||||||
|
|
||||||
int modifiedArmor = -1;
|
int modifiedArmor = -1;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ItemStack[] contents = null;
|
ItemStack[] contents = null;
|
||||||
|
|
||||||
if (type != null && type.equals(Material.ARMOR_STAND)) {
|
if (type != null && type.equals(Material.ARMOR_STAND)) {
|
||||||
|
|
||||||
EntityEquipment equipment = (EntityEquipment) container;
|
EntityEquipment equipment = (EntityEquipment) container;
|
||||||
if (equipment != null) {
|
if (equipment != null) {
|
||||||
|
|
||||||
if (action == 1) {
|
if (action == 1) {
|
||||||
|
|
||||||
itemstack.setAmount(1);
|
itemstack.setAmount(1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
itemstack.setType(Material.AIR);
|
itemstack.setType(Material.AIR);
|
||||||
itemstack.setAmount(0);
|
itemstack.setAmount(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot < 4) {
|
if (slot < 4) {
|
||||||
|
|
||||||
contents = equipment.getArmorContents();
|
contents = equipment.getArmorContents();
|
||||||
if (slot >= 0) {
|
if (slot >= 0) {
|
||||||
|
|
||||||
contents[slot] = itemstack;
|
contents[slot] = itemstack;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
equipment.setArmorContents(contents);
|
equipment.setArmorContents(contents);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ArmorStand armorStand = (ArmorStand) equipment.getHolder();
|
ArmorStand armorStand = (ArmorStand) equipment.getHolder();
|
||||||
armorStand.setArms(true);
|
armorStand.setArms(true);
|
||||||
switch (slot) {
|
switch (slot) {
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
equipment.setItemInMainHand(itemstack);
|
equipment.setItemInMainHand(itemstack);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
equipment.setItemInOffHand(itemstack);
|
equipment.setItemInOffHand(itemstack);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type != null && type.equals(Material.ITEM_FRAME)) {
|
} else if (type != null && type.equals(Material.ITEM_FRAME)) {
|
||||||
|
|
||||||
ItemFrame frame = (ItemFrame) container;
|
ItemFrame frame = (ItemFrame) container;
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
|
|
||||||
if (action == 1) {
|
if (action == 1) {
|
||||||
|
|
||||||
itemstack.setAmount(1);
|
itemstack.setAmount(1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
itemstack.setType(Material.AIR);
|
itemstack.setType(Material.AIR);
|
||||||
itemstack.setAmount(0);
|
itemstack.setAmount(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.setItem(itemstack);
|
frame.setItem(itemstack);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type != null && type.equals(Material.JUKEBOX)) {
|
} else if (type != null && type.equals(Material.JUKEBOX)) {
|
||||||
|
|
||||||
Jukebox jukebox = (Jukebox) container;
|
Jukebox jukebox = (Jukebox) container;
|
||||||
if (jukebox != null) {
|
if (jukebox != null) {
|
||||||
|
|
||||||
if (action == 1 && itemstack.getType().name().startsWith("MUSIC_DISC")) {
|
if (action == 1 && itemstack.getType().name().startsWith("MUSIC_DISC")) {
|
||||||
|
|
||||||
itemstack.setAmount(1);
|
itemstack.setAmount(1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
itemstack.setType(Material.AIR);
|
itemstack.setType(Material.AIR);
|
||||||
itemstack.setAmount(0);
|
itemstack.setAmount(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jukebox.setRecord(itemstack);
|
jukebox.setRecord(itemstack);
|
||||||
jukebox.update();
|
jukebox.update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Inventory inventory = (Inventory) container;
|
Inventory inventory = (Inventory) container;
|
||||||
if (inventory != null) {
|
if (inventory != null) {
|
||||||
|
|
||||||
boolean isPlayerInventory = (inventory instanceof PlayerInventory);
|
boolean isPlayerInventory = (inventory instanceof PlayerInventory);
|
||||||
if (action == 1) {
|
if (action == 1) {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int amount = itemstack.getAmount();
|
int amount = itemstack.getAmount();
|
||||||
itemstack.setAmount(1);
|
itemstack.setAmount(1);
|
||||||
|
|
||||||
while (count < amount) {
|
while (count < amount) {
|
||||||
|
|
||||||
boolean addedItem = false;
|
boolean addedItem = false;
|
||||||
if (isPlayerInventory) {
|
if (isPlayerInventory) {
|
||||||
|
|
||||||
int setArmor = Util.setPlayerArmor((PlayerInventory) inventory, itemstack);
|
int setArmor = Util.setPlayerArmor((PlayerInventory) inventory, itemstack);
|
||||||
addedItem = (setArmor > -1);
|
addedItem = (setArmor > -1);
|
||||||
modifiedArmor = addedItem ? setArmor : modifiedArmor;
|
modifiedArmor = addedItem ? setArmor : modifiedArmor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addedItem) {
|
if (!addedItem) {
|
||||||
|
|
||||||
if (BukkitAdapter.ADAPTER.isChiseledBookshelf(type)) {
|
if (BukkitAdapter.ADAPTER.isChiseledBookshelf(type)) {
|
||||||
|
|
||||||
ItemStack[] inventoryContents = inventory.getStorageContents();
|
ItemStack[] inventoryContents = inventory.getStorageContents();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ItemStack stack : inventoryContents) {
|
for (ItemStack stack : inventoryContents) {
|
||||||
|
|
||||||
if (stack == null) {
|
if (stack == null) {
|
||||||
|
|
||||||
inventoryContents[i] = itemstack;
|
inventoryContents[i] = itemstack;
|
||||||
addedItem = true;
|
addedItem = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addedItem) {
|
if (addedItem) {
|
||||||
|
|
||||||
inventory.setStorageContents(inventoryContents);
|
inventory.setStorageContents(inventoryContents);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
addedItem =
|
|
||||||
(inventory.addItem(itemstack).size() == 0);
|
addedItem = (inventory.addItem(itemstack).size() == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
addedItem = (inventory.addItem(itemstack).size() == 0);
|
addedItem = (inventory.addItem(itemstack).size() == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addedItem && isPlayerInventory) {
|
if (!addedItem && isPlayerInventory) {
|
||||||
|
|
||||||
PlayerInventory playerInventory = (PlayerInventory) inventory;
|
PlayerInventory playerInventory = (PlayerInventory) inventory;
|
||||||
ItemStack offhand = playerInventory.getItemInOffHand();
|
ItemStack offhand = playerInventory.getItemInOffHand();
|
||||||
if (offhand == null
|
if (offhand == null || offhand.getType() == Material.AIR
|
||||||
|| offhand.getType() == Material.AIR
|
|
||||||
|| (itemstack.isSimilar(offhand)
|
|| (itemstack.isSimilar(offhand)
|
||||||
&& offhand.getAmount() < offhand.getMaxStackSize())) {
|
&& offhand.getAmount() < offhand.getMaxStackSize()))
|
||||||
|
{
|
||||||
|
|
||||||
ItemStack setOffhand = itemstack.clone();
|
ItemStack setOffhand = itemstack.clone();
|
||||||
if (itemstack.isSimilar(offhand)) {
|
if (itemstack.isSimilar(offhand)) {
|
||||||
|
|
||||||
setOffhand.setAmount(offhand.getAmount() + 1);
|
setOffhand.setAmount(offhand.getAmount() + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playerInventory.setItemInOffHand(setOffhand);
|
playerInventory.setItemInOffHand(setOffhand);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int removeAmount = itemstack.getAmount();
|
int removeAmount = itemstack.getAmount();
|
||||||
ItemStack removeMatch = itemstack.clone();
|
ItemStack removeMatch = itemstack.clone();
|
||||||
removeMatch.setAmount(1);
|
removeMatch.setAmount(1);
|
||||||
|
|
||||||
ItemStack[] inventoryContents =
|
ItemStack[] inventoryContents = (isPlayerInventory ? inventory.getContents()
|
||||||
(isPlayerInventory ? inventory.getContents() : inventory.getStorageContents()).clone();
|
: inventory.getStorageContents()).clone();
|
||||||
for (int i = inventoryContents.length - 1; i >= 0; i--) {
|
for (int i = inventoryContents.length - 1; i >= 0; i--) {
|
||||||
|
|
||||||
if (inventoryContents[i] != null) {
|
if (inventoryContents[i] != null) {
|
||||||
|
|
||||||
ItemStack itemStack = inventoryContents[i].clone();
|
ItemStack itemStack = inventoryContents[i].clone();
|
||||||
int maxAmount = itemStack.getAmount();
|
int maxAmount = itemStack.getAmount();
|
||||||
int currentAmount = maxAmount;
|
int currentAmount = maxAmount;
|
||||||
itemStack.setAmount(1);
|
itemStack.setAmount(1);
|
||||||
|
|
||||||
if (itemStack.toString().equals(removeMatch.toString())) {
|
if (itemStack.toString().equals(removeMatch.toString())) {
|
||||||
|
|
||||||
for (int scan = 0; scan < maxAmount; scan++) {
|
for (int scan = 0; scan < maxAmount; scan++) {
|
||||||
|
|
||||||
if (removeAmount > 0) {
|
if (removeAmount > 0) {
|
||||||
|
|
||||||
currentAmount--;
|
currentAmount--;
|
||||||
itemStack.setAmount(currentAmount);
|
itemStack.setAmount(currentAmount);
|
||||||
removeAmount--;
|
removeAmount--;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
itemStack.setAmount(maxAmount);
|
itemStack.setAmount(maxAmount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemStack.getAmount() == 0) {
|
if (itemStack.getAmount() == 0) {
|
||||||
|
|
||||||
inventoryContents[i] = null;
|
inventoryContents[i] = null;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
inventoryContents[i] = itemStack;
|
inventoryContents[i] = itemStack;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removeAmount == 0) {
|
if (removeAmount == 0) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPlayerInventory) {
|
if (isPlayerInventory) {
|
||||||
|
|
||||||
inventory.setContents(inventoryContents);
|
inventory.setContents(inventoryContents);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
inventory.setStorageContents(inventoryContents);
|
inventory.setStorageContents(inventoryContents);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (count < removeAmount) {
|
while (count < removeAmount) {
|
||||||
|
|
||||||
inventory.removeItem(removeMatch);
|
inventory.removeItem(removeMatch);
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return modifiedArmor;
|
return modifiedArmor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sortContainerItems(PlayerInventory inventory, List<Integer> modifiedArmorSlots) {
|
public static void sortContainerItems(PlayerInventory inventory, List<Integer> modifiedArmorSlots) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ItemStack[] armorContents = inventory.getArmorContents();
|
ItemStack[] armorContents = inventory.getArmorContents();
|
||||||
ItemStack[] storageContents = inventory.getStorageContents();
|
ItemStack[] storageContents = inventory.getStorageContents();
|
||||||
|
|
||||||
for (int armor = 0; armor < armorContents.length; armor++) {
|
for (int armor = 0; armor < armorContents.length; armor++) {
|
||||||
|
|
||||||
ItemStack armorItem = armorContents[armor];
|
ItemStack armorItem = armorContents[armor];
|
||||||
if (armorItem == null || !modifiedArmorSlots.contains(armor)) {
|
if (armorItem == null || !modifiedArmorSlots.contains(armor)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int storage = 0; storage < storageContents.length; storage++) {
|
for (int storage = 0; storage < storageContents.length; storage++) {
|
||||||
|
|
||||||
ItemStack storageItem = storageContents[storage];
|
ItemStack storageItem = storageContents[storage];
|
||||||
if (storageItem == null) {
|
if (storageItem == null) {
|
||||||
|
|
||||||
storageContents[storage] = armorItem;
|
storageContents[storage] = armorItem;
|
||||||
armorContents[armor] = null;
|
armorContents[armor] = null;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.setArmorContents(armorContents);
|
inventory.setArmorContents(armorContents);
|
||||||
inventory.setStorageContents(storageContents);
|
inventory.setStorageContents(storageContents);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void buildFireworkEffect(Builder effectBuilder, Material rowType, ItemStack itemstack) {
|
private static void buildFireworkEffect(Builder effectBuilder, Material rowType, ItemStack itemstack) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
FireworkEffect effect = effectBuilder.build();
|
FireworkEffect effect = effectBuilder.build();
|
||||||
if ((rowType == Material.FIREWORK_ROCKET)) {
|
if ((rowType == Material.FIREWORK_ROCKET)) {
|
||||||
|
|
||||||
FireworkMeta meta = (FireworkMeta) itemstack.getItemMeta();
|
FireworkMeta meta = (FireworkMeta) itemstack.getItemMeta();
|
||||||
meta.addEffect(effect);
|
meta.addEffect(effect);
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
} else if ((rowType == Material.FIREWORK_STAR)) {
|
} else if ((rowType == Material.FIREWORK_STAR)) {
|
||||||
|
|
||||||
FireworkEffectMeta meta = (FireworkEffectMeta) itemstack.getItemMeta();
|
FireworkEffectMeta meta = (FireworkEffectMeta) itemstack.getItemMeta();
|
||||||
meta.setEffect(effect);
|
meta.setEffect(effect);
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Object[] populateItemStack(ItemStack itemstack, Object list) {
|
public static Object[] populateItemStack(ItemStack itemstack, Object list) {
|
||||||
|
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
String faceData = "";
|
String faceData = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/*
|
/*
|
||||||
if (list instanceof Object[]) {
|
* if (list instanceof Object[]) { slot = (int) ((Object[]) list)[0]; ItemMeta
|
||||||
slot = (int) ((Object[]) list)[0];
|
* itemMeta = (ItemMeta) ((Object[]) list)[1]; itemstack.setItemMeta(itemMeta);
|
||||||
ItemMeta itemMeta = (ItemMeta) ((Object[]) list)[1];
|
* return new Object[] { slot, itemstack }; }
|
||||||
itemstack.setItemMeta(itemMeta);
|
*/
|
||||||
return new Object[] { slot, itemstack };
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
Material rowType = itemstack.getType();
|
Material rowType = itemstack.getType();
|
||||||
List<Object> metaList = (List<Object>) list;
|
List<Object> metaList = (List<Object>) list;
|
||||||
if (metaList.size() > 0 && !(metaList.get(0) instanceof List<?>)) {
|
if (metaList.size() > 0 && !(metaList.get(0) instanceof List<?>)) {
|
||||||
|
|
||||||
if (rowType.name().endsWith("_BANNER")) {
|
if (rowType.name().endsWith("_BANNER")) {
|
||||||
|
|
||||||
BannerMeta meta = (BannerMeta) itemstack.getItemMeta();
|
BannerMeta meta = (BannerMeta) itemstack.getItemMeta();
|
||||||
for (Object value : metaList) {
|
for (Object value : metaList) {
|
||||||
|
|
||||||
if (value instanceof Map) {
|
if (value instanceof Map) {
|
||||||
|
|
||||||
Pattern pattern = new Pattern((Map<String, Object>) value);
|
Pattern pattern = new Pattern((Map<String, Object>) value);
|
||||||
meta.addPattern(pattern);
|
meta.addPattern(pattern);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
} else if (BlockGroup.SHULKER_BOXES.contains(rowType)) {
|
} else if (BlockGroup.SHULKER_BOXES.contains(rowType)) {
|
||||||
|
|
||||||
BlockStateMeta meta = (BlockStateMeta) itemstack.getItemMeta();
|
BlockStateMeta meta = (BlockStateMeta) itemstack.getItemMeta();
|
||||||
ShulkerBox shulkerBox = (ShulkerBox) meta.getBlockState();
|
ShulkerBox shulkerBox = (ShulkerBox) meta.getBlockState();
|
||||||
for (Object value : metaList) {
|
for (Object value : metaList) {
|
||||||
|
|
||||||
ItemStack item = Util.unserializeItemStackLegacy(value);
|
ItemStack item = Util.unserializeItemStackLegacy(value);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
|
||||||
shulkerBox.getInventory().addItem(item);
|
shulkerBox.getInventory().addItem(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.setBlockState(shulkerBox);
|
meta.setBlockState(shulkerBox);
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Object[] {slot, faceData, itemstack};
|
return new Object[] { slot, faceData, itemstack };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int itemCount = 0;
|
int itemCount = 0;
|
||||||
Builder effectBuilder = FireworkEffect.builder();
|
Builder effectBuilder = FireworkEffect.builder();
|
||||||
for (List<Map<String, Object>> map : (List<List<Map<String, Object>>>) list) {
|
for (List<Map<String, Object>> map : (List<List<Map<String, Object>>>) list) {
|
||||||
|
|
||||||
if (map.size() == 0) {
|
if (map.size() == 0) {
|
||||||
|
|
||||||
if (itemCount == 3 && (rowType == Material.FIREWORK_ROCKET || rowType == Material.FIREWORK_STAR)) {
|
if (itemCount == 3 && (rowType == Material.FIREWORK_ROCKET || rowType == Material.FIREWORK_STAR)) {
|
||||||
|
|
||||||
buildFireworkEffect(effectBuilder, rowType, itemstack);
|
buildFireworkEffect(effectBuilder, rowType, itemstack);
|
||||||
itemCount = 0;
|
itemCount = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemCount++;
|
itemCount++;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> mapData = map.get(0);
|
Map<String, Object> mapData = map.get(0);
|
||||||
|
|
||||||
if (mapData.get("slot") != null) {
|
if (mapData.get("slot") != null) {
|
||||||
|
|
||||||
slot = (Integer) mapData.get("slot");
|
slot = (Integer) mapData.get("slot");
|
||||||
|
|
||||||
} else if (mapData.get("facing") != null) {
|
} else if (mapData.get("facing") != null) {
|
||||||
|
|
||||||
faceData = (String) mapData.get("facing");
|
faceData = (String) mapData.get("facing");
|
||||||
|
|
||||||
} else if (mapData.get("modifiers") != null) {
|
} else if (mapData.get("modifiers") != null) {
|
||||||
|
|
||||||
ItemMeta itemMeta = itemstack.getItemMeta();
|
ItemMeta itemMeta = itemstack.getItemMeta();
|
||||||
if (itemMeta.hasAttributeModifiers()) {
|
if (itemMeta.hasAttributeModifiers()) {
|
||||||
for (Map.Entry<Attribute, AttributeModifier> entry :
|
|
||||||
itemMeta.getAttributeModifiers().entries()) {
|
for (Map.Entry<Attribute, AttributeModifier> entry : itemMeta.getAttributeModifiers()
|
||||||
|
.entries())
|
||||||
|
{
|
||||||
|
|
||||||
itemMeta.removeAttributeModifier(entry.getKey(), entry.getValue());
|
itemMeta.removeAttributeModifier(entry.getKey(), entry.getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Object> modifiers = (List<Object>) mapData.get("modifiers");
|
List<Object> modifiers = (List<Object>) mapData.get("modifiers");
|
||||||
|
|
||||||
for (Object item : modifiers) {
|
for (Object item : modifiers) {
|
||||||
|
|
||||||
Map<Object, Map<String, Object>> modifiersMap = (Map<Object, Map<String, Object>>) item;
|
Map<Object, Map<String, Object>> modifiersMap = (Map<Object, Map<String, Object>>) item;
|
||||||
for (Map.Entry<Object, Map<String, Object>> entry : modifiersMap.entrySet()) {
|
for (Map.Entry<Object, Map<String, Object>> entry : modifiersMap.entrySet()) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Attribute attribute = null;
|
Attribute attribute = null;
|
||||||
if (entry.getKey() instanceof Attribute) {
|
if (entry.getKey() instanceof Attribute) {
|
||||||
|
|
||||||
attribute = (Attribute) entry.getKey();
|
attribute = (Attribute) entry.getKey();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
attribute = (Attribute) BukkitAdapter.ADAPTER.getRegistryValue(
|
|
||||||
(String) entry.getKey(), Attribute.class);
|
attribute = (Attribute) BukkitAdapter.ADAPTER
|
||||||
|
.getRegistryValue((String) entry.getKey(), Attribute.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributeModifier modifier = AttributeModifier.deserialize(entry.getValue());
|
AttributeModifier modifier = AttributeModifier.deserialize(entry.getValue());
|
||||||
itemMeta.addAttributeModifier(attribute, modifier);
|
itemMeta.addAttributeModifier(attribute, modifier);
|
||||||
|
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
|
||||||
// AttributeModifier already exists
|
// AttributeModifier already exists
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemstack.setItemMeta(itemMeta);
|
itemstack.setItemMeta(itemMeta);
|
||||||
|
|
||||||
} else if (itemCount == 0) {
|
} else if (itemCount == 0) {
|
||||||
ItemMeta meta =
|
|
||||||
Util.deserializeItemMeta(itemstack.getItemMeta().getClass(), map.get(0));
|
ItemMeta meta = Util.deserializeItemMeta(itemstack.getItemMeta().getClass(), map.get(0));
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
if (map.size() > 1 && (rowType == Material.POTION)) {
|
if (map.size() > 1 && (rowType == Material.POTION)) {
|
||||||
|
|
||||||
PotionMeta subMeta = (PotionMeta) itemstack.getItemMeta();
|
PotionMeta subMeta = (PotionMeta) itemstack.getItemMeta();
|
||||||
org.bukkit.Color color = org.bukkit.Color.deserialize(map.get(1));
|
org.bukkit.Color color = org.bukkit.Color.deserialize(map.get(1));
|
||||||
subMeta.setColor(color);
|
subMeta.setColor(color);
|
||||||
itemstack.setItemMeta(subMeta);
|
itemstack.setItemMeta(subMeta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ((rowType == Material.LEATHER_HORSE_ARMOR)
|
|
||||||
|| (rowType == Material.LEATHER_HELMET)
|
if ((rowType == Material.LEATHER_HORSE_ARMOR) || (rowType == Material.LEATHER_HELMET)
|
||||||
|| (rowType == Material.LEATHER_CHESTPLATE)
|
|| (rowType == Material.LEATHER_CHESTPLATE) || (rowType == Material.LEATHER_LEGGINGS)
|
||||||
|| (rowType == Material.LEATHER_LEGGINGS)
|
|| (rowType == Material.LEATHER_BOOTS))
|
||||||
|| (rowType == Material.LEATHER_BOOTS)) { // leather armor
|
{ // leather armor
|
||||||
|
|
||||||
for (Map<String, Object> colorData : map) {
|
for (Map<String, Object> colorData : map) {
|
||||||
|
|
||||||
LeatherArmorMeta meta = (LeatherArmorMeta) itemstack.getItemMeta();
|
LeatherArmorMeta meta = (LeatherArmorMeta) itemstack.getItemMeta();
|
||||||
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
||||||
meta.setColor(color);
|
meta.setColor(color);
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ((rowType == Material.POTION)) { // potion
|
} else if ((rowType == Material.POTION)) { // potion
|
||||||
|
|
||||||
for (Map<String, Object> potionData : map) {
|
for (Map<String, Object> potionData : map) {
|
||||||
|
|
||||||
PotionMeta meta = (PotionMeta) itemstack.getItemMeta();
|
PotionMeta meta = (PotionMeta) itemstack.getItemMeta();
|
||||||
PotionEffect effect = new PotionEffect(potionData);
|
PotionEffect effect = new PotionEffect(potionData);
|
||||||
meta.addCustomEffect(effect, true);
|
meta.addCustomEffect(effect, true);
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (rowType.name().endsWith("_BANNER")) {
|
} else if (rowType.name().endsWith("_BANNER")) {
|
||||||
|
|
||||||
for (Map<String, Object> patternData : map) {
|
for (Map<String, Object> patternData : map) {
|
||||||
|
|
||||||
BannerMeta meta = (BannerMeta) itemstack.getItemMeta();
|
BannerMeta meta = (BannerMeta) itemstack.getItemMeta();
|
||||||
Pattern pattern = new Pattern(patternData);
|
Pattern pattern = new Pattern(patternData);
|
||||||
meta.addPattern(pattern);
|
meta.addPattern(pattern);
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ((rowType == Material.CROSSBOW)) {
|
} else if ((rowType == Material.CROSSBOW)) {
|
||||||
|
|
||||||
CrossbowMeta meta = (CrossbowMeta) itemstack.getItemMeta();
|
CrossbowMeta meta = (CrossbowMeta) itemstack.getItemMeta();
|
||||||
for (Map<String, Object> itemData : map) {
|
for (Map<String, Object> itemData : map) {
|
||||||
|
|
||||||
ItemStack crossbowItem = Util.unserializeItemStack(itemData);
|
ItemStack crossbowItem = Util.unserializeItemStack(itemData);
|
||||||
if (crossbowItem != null) {
|
if (crossbowItem != null) {
|
||||||
|
|
||||||
meta.addChargedProjectile(crossbowItem);
|
meta.addChargedProjectile(crossbowItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
} else if (rowType == Material.MAP || rowType == Material.FILLED_MAP) {
|
} else if (rowType == Material.MAP || rowType == Material.FILLED_MAP) {
|
||||||
|
|
||||||
for (Map<String, Object> colorData : map) {
|
for (Map<String, Object> colorData : map) {
|
||||||
|
|
||||||
MapMeta meta = (MapMeta) itemstack.getItemMeta();
|
MapMeta meta = (MapMeta) itemstack.getItemMeta();
|
||||||
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
||||||
meta.setColor(color);
|
meta.setColor(color);
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ((rowType == Material.FIREWORK_ROCKET) || (rowType == Material.FIREWORK_STAR)) {
|
} else if ((rowType == Material.FIREWORK_ROCKET) || (rowType == Material.FIREWORK_STAR)) {
|
||||||
|
|
||||||
if (itemCount == 1) {
|
if (itemCount == 1) {
|
||||||
|
|
||||||
effectBuilder = FireworkEffect.builder();
|
effectBuilder = FireworkEffect.builder();
|
||||||
for (Map<String, Object> fireworkData : map) {
|
for (Map<String, Object> fireworkData : map) {
|
||||||
org.bukkit.FireworkEffect.Type type = (org.bukkit.FireworkEffect.Type)
|
|
||||||
fireworkData.getOrDefault("type", org.bukkit.FireworkEffect.Type.BALL);
|
org.bukkit.FireworkEffect.Type type = (org.bukkit.FireworkEffect.Type) fireworkData
|
||||||
|
.getOrDefault("type", org.bukkit.FireworkEffect.Type.BALL);
|
||||||
boolean hasFlicker = (Boolean) fireworkData.get("flicker");
|
boolean hasFlicker = (Boolean) fireworkData.get("flicker");
|
||||||
boolean hasTrail = (Boolean) fireworkData.get("trail");
|
boolean hasTrail = (Boolean) fireworkData.get("trail");
|
||||||
effectBuilder.with(type);
|
effectBuilder.with(type);
|
||||||
effectBuilder.flicker(hasFlicker);
|
effectBuilder.flicker(hasFlicker);
|
||||||
effectBuilder.trail(hasTrail);
|
effectBuilder.trail(hasTrail);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (itemCount == 2) {
|
} else if (itemCount == 2) {
|
||||||
|
|
||||||
for (Map<String, Object> colorData : map) {
|
for (Map<String, Object> colorData : map) {
|
||||||
|
|
||||||
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
||||||
effectBuilder.withColor(color);
|
effectBuilder.withColor(color);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (itemCount == 3) {
|
} else if (itemCount == 3) {
|
||||||
|
|
||||||
for (Map<String, Object> colorData : map) {
|
for (Map<String, Object> colorData : map) {
|
||||||
|
|
||||||
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
org.bukkit.Color color = org.bukkit.Color.deserialize(colorData);
|
||||||
effectBuilder.withFade(color);
|
effectBuilder.withFade(color);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFireworkEffect(effectBuilder, rowType, itemstack);
|
buildFireworkEffect(effectBuilder, rowType, itemstack);
|
||||||
itemCount = 0;
|
itemCount = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ((rowType == Material.SUSPICIOUS_STEW)) {
|
} else if ((rowType == Material.SUSPICIOUS_STEW)) {
|
||||||
|
|
||||||
for (Map<String, Object> suspiciousStewData : map) {
|
for (Map<String, Object> suspiciousStewData : map) {
|
||||||
|
|
||||||
SuspiciousStewMeta meta = (SuspiciousStewMeta) itemstack.getItemMeta();
|
SuspiciousStewMeta meta = (SuspiciousStewMeta) itemstack.getItemMeta();
|
||||||
PotionEffect effect = new PotionEffect(suspiciousStewData);
|
PotionEffect effect = new PotionEffect(suspiciousStewData);
|
||||||
meta.addCustomEffect(effect, true);
|
meta.addCustomEffect(effect, true);
|
||||||
itemstack.setItemMeta(meta);
|
itemstack.setItemMeta(meta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
BukkitAdapter.ADAPTER.setItemMeta(rowType, itemstack, map);
|
BukkitAdapter.ADAPTER.setItemMeta(rowType, itemstack, map);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemCount++;
|
itemCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
return new Object[] {slot, faceData, itemstack};
|
|
||||||
|
return new Object[] { slot, faceData, itemstack };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object[] populateItemStack(ItemStack itemstack, byte[] metadata) {
|
public static Object[] populateItemStack(ItemStack itemstack, byte[] metadata) {
|
||||||
|
|
||||||
if (metadata != null) {
|
if (metadata != null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ByteArrayInputStream metaByteStream = new ByteArrayInputStream(metadata);
|
ByteArrayInputStream metaByteStream = new ByteArrayInputStream(metadata);
|
||||||
BukkitObjectInputStream metaObjectStream = new BukkitObjectInputStream(metaByteStream);
|
BukkitObjectInputStream metaObjectStream = new BukkitObjectInputStream(metaByteStream);
|
||||||
Object metaList = metaObjectStream.readObject();
|
Object metaList = metaObjectStream.readObject();
|
||||||
@@ -458,11 +683,17 @@ public class RollbackUtil extends Lookup {
|
|||||||
metaByteStream.close();
|
metaByteStream.close();
|
||||||
|
|
||||||
return populateItemStack(itemstack, metaList);
|
return populateItemStack(itemstack, metaList);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Object[] {0, "", itemstack};
|
return new Object[] { 0, "", itemstack };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,30 +7,24 @@ import net.coreprotect.utility.Util;
|
|||||||
public class BlockStatement {
|
public class BlockStatement {
|
||||||
|
|
||||||
private BlockStatement() {
|
private BlockStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insert(
|
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y,
|
||||||
PreparedStatement preparedStmt,
|
int z, int type, int data, List<Object> meta, String blockData, int action, int rolledBack)
|
||||||
int batchCount,
|
{
|
||||||
int time,
|
|
||||||
int id,
|
|
||||||
int wid,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int z,
|
|
||||||
int type,
|
|
||||||
int data,
|
|
||||||
List<Object> meta,
|
|
||||||
String blockData,
|
|
||||||
int action,
|
|
||||||
int rolledBack) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
byte[] bBlockData = Util.stringToByteData(blockData, type);
|
byte[] bBlockData = Util.stringToByteData(blockData, type);
|
||||||
byte[] byteData = null;
|
byte[] byteData = null;
|
||||||
|
|
||||||
if (meta != null) {
|
if (meta != null) {
|
||||||
|
|
||||||
byteData = Util.convertByteData(meta);
|
byteData = Util.convertByteData(meta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preparedStmt.setInt(1, time);
|
preparedStmt.setInt(1, time);
|
||||||
@@ -48,10 +42,17 @@ public class BlockStatement {
|
|||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
|
|
||||||
if (batchCount > 0 && batchCount % 1000 == 0) {
|
if (batchCount > 0 && batchCount % 1000 == 0) {
|
||||||
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,20 +5,17 @@ import java.sql.PreparedStatement;
|
|||||||
public class ChatStatement {
|
public class ChatStatement {
|
||||||
|
|
||||||
private ChatStatement() {
|
private ChatStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insert(
|
public static void insert(PreparedStatement preparedStmt, int batchCount, long time, int user, int wid, int x,
|
||||||
PreparedStatement preparedStmt,
|
int y, int z, String message)
|
||||||
int batchCount,
|
{
|
||||||
long time,
|
|
||||||
int user,
|
|
||||||
int wid,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int z,
|
|
||||||
String message) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
preparedStmt.setLong(1, time);
|
preparedStmt.setLong(1, time);
|
||||||
preparedStmt.setInt(2, user);
|
preparedStmt.setInt(2, user);
|
||||||
preparedStmt.setInt(3, wid);
|
preparedStmt.setInt(3, wid);
|
||||||
@@ -29,10 +26,17 @@ public class ChatStatement {
|
|||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
|
|
||||||
if (batchCount > 0 && batchCount % 1000 == 0) {
|
if (batchCount > 0 && batchCount % 1000 == 0) {
|
||||||
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,20 +5,17 @@ import java.sql.PreparedStatement;
|
|||||||
public class CommandStatement {
|
public class CommandStatement {
|
||||||
|
|
||||||
private CommandStatement() {
|
private CommandStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insert(
|
public static void insert(PreparedStatement preparedStmt, int batchCount, long time, int user, int wid, int x,
|
||||||
PreparedStatement preparedStmt,
|
int y, int z, String message)
|
||||||
int batchCount,
|
{
|
||||||
long time,
|
|
||||||
int user,
|
|
||||||
int wid,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int z,
|
|
||||||
String message) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
preparedStmt.setLong(1, time);
|
preparedStmt.setLong(1, time);
|
||||||
preparedStmt.setInt(2, user);
|
preparedStmt.setInt(2, user);
|
||||||
preparedStmt.setInt(3, wid);
|
preparedStmt.setInt(3, wid);
|
||||||
@@ -29,10 +26,17 @@ public class CommandStatement {
|
|||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
|
|
||||||
if (batchCount > 0 && batchCount % 1000 == 0) {
|
if (batchCount > 0 && batchCount % 1000 == 0) {
|
||||||
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,25 +6,17 @@ import net.coreprotect.utility.Util;
|
|||||||
public class ContainerStatement {
|
public class ContainerStatement {
|
||||||
|
|
||||||
private ContainerStatement() {
|
private ContainerStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insert(
|
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y,
|
||||||
PreparedStatement preparedStmt,
|
int z, int type, int data, int amount, Object metadata, int action, int rolledBack)
|
||||||
int batchCount,
|
{
|
||||||
int time,
|
|
||||||
int id,
|
|
||||||
int wid,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int z,
|
|
||||||
int type,
|
|
||||||
int data,
|
|
||||||
int amount,
|
|
||||||
Object metadata,
|
|
||||||
int action,
|
|
||||||
int rolledBack) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
byte[] byteData = Util.convertByteData(metadata);
|
byte[] byteData = Util.convertByteData(metadata);
|
||||||
preparedStmt.setInt(1, time);
|
preparedStmt.setInt(1, time);
|
||||||
preparedStmt.setInt(2, id);
|
preparedStmt.setInt(2, id);
|
||||||
@@ -41,10 +33,17 @@ public class ContainerStatement {
|
|||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
|
|
||||||
if (batchCount > 0 && batchCount % 1000 == 0) {
|
if (batchCount > 0 && batchCount % 1000 == 0) {
|
||||||
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,11 +16,15 @@ import org.bukkit.util.io.BukkitObjectOutputStream;
|
|||||||
public class EntityStatement {
|
public class EntityStatement {
|
||||||
|
|
||||||
private EntityStatement() {
|
private EntityStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResultSet insert(PreparedStatement preparedStmt, int time, List<Object> data) {
|
public static ResultSet insert(PreparedStatement preparedStmt, int time, List<Object> data) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
BukkitObjectOutputStream oos = new BukkitObjectOutputStream(bos);
|
BukkitObjectOutputStream oos = new BukkitObjectOutputStream(bos);
|
||||||
oos.writeObject(data);
|
oos.writeObject(data);
|
||||||
@@ -32,23 +36,34 @@ public class EntityStatement {
|
|||||||
preparedStmt.setInt(1, time);
|
preparedStmt.setInt(1, time);
|
||||||
preparedStmt.setObject(2, byte_data);
|
preparedStmt.setObject(2, byte_data);
|
||||||
if (Database.hasReturningKeys()) {
|
if (Database.hasReturningKeys()) {
|
||||||
|
|
||||||
return preparedStmt.executeQuery();
|
return preparedStmt.executeQuery();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
preparedStmt.executeUpdate();
|
preparedStmt.executeUpdate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Object> getData(Statement statement, BlockState block, String query) {
|
public static List<Object> getData(Statement statement, BlockState block, String query) {
|
||||||
|
|
||||||
List<Object> result = new ArrayList<>();
|
List<Object> result = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ResultSet resultSet = statement.executeQuery(query);
|
ResultSet resultSet = statement.executeQuery(query);
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
|
|
||||||
byte[] data = resultSet.getBytes("data");
|
byte[] data = resultSet.getBytes("data");
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||||
BukkitObjectInputStream ins = new BukkitObjectInputStream(bais);
|
BukkitObjectInputStream ins = new BukkitObjectInputStream(bais);
|
||||||
@@ -57,15 +72,23 @@ public class EntityStatement {
|
|||||||
ins.close();
|
ins.close();
|
||||||
bais.close();
|
bais.close();
|
||||||
result = input;
|
result = input;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
|
|
||||||
} catch (Exception e) { // only display exception on development branch
|
} catch (Exception e) { // only display exception on development branch
|
||||||
|
|
||||||
if (!ConfigHandler.EDITION_BRANCH.contains("-dev")) {
|
if (!ConfigHandler.EDITION_BRANCH.contains("-dev")) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,23 +6,17 @@ import net.coreprotect.utility.Util;
|
|||||||
public class ItemStatement {
|
public class ItemStatement {
|
||||||
|
|
||||||
private ItemStatement() {
|
private ItemStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insert(
|
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y,
|
||||||
PreparedStatement preparedStmt,
|
int z, int type, Object data, int amount, int action)
|
||||||
int batchCount,
|
{
|
||||||
int time,
|
|
||||||
int id,
|
|
||||||
int wid,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int z,
|
|
||||||
int type,
|
|
||||||
Object data,
|
|
||||||
int amount,
|
|
||||||
int action) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
byte[] byteData = Util.convertByteData(data);
|
byte[] byteData = Util.convertByteData(data);
|
||||||
preparedStmt.setInt(1, time);
|
preparedStmt.setInt(1, time);
|
||||||
preparedStmt.setInt(2, id);
|
preparedStmt.setInt(2, id);
|
||||||
@@ -38,10 +32,17 @@ public class ItemStatement {
|
|||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
|
|
||||||
if (batchCount > 0 && batchCount % 1000 == 0) {
|
if (batchCount > 0 && batchCount % 1000 == 0) {
|
||||||
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,36 +7,56 @@ import java.sql.Statement;
|
|||||||
public class MaterialStatement {
|
public class MaterialStatement {
|
||||||
|
|
||||||
private MaterialStatement() {
|
private MaterialStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insert(PreparedStatement preparedStmt, int batchCount, int id, String name) {
|
public static void insert(PreparedStatement preparedStmt, int batchCount, int id, String name) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
preparedStmt.setInt(1, id);
|
preparedStmt.setInt(1, id);
|
||||||
preparedStmt.setString(2, name);
|
preparedStmt.setString(2, name);
|
||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
|
|
||||||
if (batchCount > 0 && batchCount % 1000 == 0) {
|
if (batchCount > 0 && batchCount % 1000 == 0) {
|
||||||
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasMaterial(Statement statement, String query) {
|
public static boolean hasMaterial(Statement statement, String query) {
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ResultSet resultSet = statement.executeQuery(query);
|
ResultSet resultSet = statement.executeQuery(query);
|
||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,20 +5,17 @@ import java.sql.PreparedStatement;
|
|||||||
public class SessionStatement {
|
public class SessionStatement {
|
||||||
|
|
||||||
private SessionStatement() {
|
private SessionStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insert(
|
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int user, int wid, int x, int y,
|
||||||
PreparedStatement preparedStmt,
|
int z, int action)
|
||||||
int batchCount,
|
{
|
||||||
int time,
|
|
||||||
int user,
|
|
||||||
int wid,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int z,
|
|
||||||
int action) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
preparedStmt.setInt(1, time);
|
preparedStmt.setInt(1, time);
|
||||||
preparedStmt.setInt(2, user);
|
preparedStmt.setInt(2, user);
|
||||||
preparedStmt.setInt(3, wid);
|
preparedStmt.setInt(3, wid);
|
||||||
@@ -29,10 +26,17 @@ public class SessionStatement {
|
|||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
|
|
||||||
if (batchCount > 0 && batchCount % 1000 == 0) {
|
if (batchCount > 0 && batchCount % 1000 == 0) {
|
||||||
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,33 +11,18 @@ import org.bukkit.block.Sign;
|
|||||||
public class SignStatement {
|
public class SignStatement {
|
||||||
|
|
||||||
private SignStatement() {
|
private SignStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insert(
|
public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y,
|
||||||
PreparedStatement preparedStmt,
|
int z, int action, int color, int colorSecondary, int data, int waxed, int face, String line1, String line2,
|
||||||
int batchCount,
|
String line3, String line4, String line5, String line6, String line7, String line8)
|
||||||
int time,
|
{
|
||||||
int id,
|
|
||||||
int wid,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int z,
|
|
||||||
int action,
|
|
||||||
int color,
|
|
||||||
int colorSecondary,
|
|
||||||
int data,
|
|
||||||
int waxed,
|
|
||||||
int face,
|
|
||||||
String line1,
|
|
||||||
String line2,
|
|
||||||
String line3,
|
|
||||||
String line4,
|
|
||||||
String line5,
|
|
||||||
String line6,
|
|
||||||
String line7,
|
|
||||||
String line8) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
preparedStmt.setInt(1, time);
|
preparedStmt.setInt(1, time);
|
||||||
preparedStmt.setInt(2, id);
|
preparedStmt.setInt(2, id);
|
||||||
preparedStmt.setInt(3, wid);
|
preparedStmt.setInt(3, wid);
|
||||||
@@ -61,23 +46,34 @@ public class SignStatement {
|
|||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
|
|
||||||
if (batchCount > 0 && batchCount % 1000 == 0) {
|
if (batchCount > 0 && batchCount % 1000 == 0) {
|
||||||
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getData(Statement statement, BlockState block, String query) {
|
public static void getData(Statement statement, BlockState block, String query) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!(block instanceof Sign)) {
|
if (!(block instanceof Sign)) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Sign sign = (Sign) block;
|
Sign sign = (Sign) block;
|
||||||
ResultSet resultSet = statement.executeQuery(query);
|
ResultSet resultSet = statement.executeQuery(query);
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
|
|
||||||
int color = resultSet.getInt("color");
|
int color = resultSet.getInt("color");
|
||||||
int colorSecondary = resultSet.getInt("color_secondary");
|
int colorSecondary = resultSet.getInt("color_secondary");
|
||||||
int data = resultSet.getInt("data");
|
int data = resultSet.getInt("data");
|
||||||
@@ -93,10 +89,15 @@ public class SignStatement {
|
|||||||
String line8 = resultSet.getString("line_8");
|
String line8 = resultSet.getString("line_8");
|
||||||
|
|
||||||
if (color > 0) {
|
if (color > 0) {
|
||||||
|
|
||||||
BukkitAdapter.ADAPTER.setColor(sign, true, color);
|
BukkitAdapter.ADAPTER.setColor(sign, true, color);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colorSecondary > 0) {
|
if (colorSecondary > 0) {
|
||||||
|
|
||||||
BukkitAdapter.ADAPTER.setColor(sign, false, colorSecondary);
|
BukkitAdapter.ADAPTER.setColor(sign, false, colorSecondary);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean frontGlowing = Util.isSideGlowing(true, data);
|
boolean frontGlowing = Util.isSideGlowing(true, data);
|
||||||
@@ -112,11 +113,17 @@ public class SignStatement {
|
|||||||
BukkitAdapter.ADAPTER.setLine(sign, 6, line7);
|
BukkitAdapter.ADAPTER.setLine(sign, 6, line7);
|
||||||
BukkitAdapter.ADAPTER.setLine(sign, 7, line8);
|
BukkitAdapter.ADAPTER.setLine(sign, 7, line8);
|
||||||
BukkitAdapter.ADAPTER.setWaxed(sign, isWaxed);
|
BukkitAdapter.ADAPTER.setWaxed(sign, isWaxed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,50 +11,77 @@ import org.bukkit.block.Skull;
|
|||||||
public class SkullStatement {
|
public class SkullStatement {
|
||||||
|
|
||||||
private SkullStatement() {
|
private SkullStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResultSet insert(PreparedStatement preparedStmt, int time, String owner, String skin) {
|
public static ResultSet insert(PreparedStatement preparedStmt, int time, String owner, String skin) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
preparedStmt.setInt(1, time);
|
preparedStmt.setInt(1, time);
|
||||||
preparedStmt.setString(2, owner);
|
preparedStmt.setString(2, owner);
|
||||||
preparedStmt.setString(3, skin);
|
preparedStmt.setString(3, skin);
|
||||||
if (Database.hasReturningKeys()) {
|
if (Database.hasReturningKeys()) {
|
||||||
|
|
||||||
return preparedStmt.executeQuery();
|
return preparedStmt.executeQuery();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
preparedStmt.executeUpdate();
|
preparedStmt.executeUpdate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getData(Statement statement, BlockState block, String query) {
|
public static void getData(Statement statement, BlockState block, String query) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!(block instanceof Skull)) {
|
if (!(block instanceof Skull)) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Skull skull = (Skull) block;
|
Skull skull = (Skull) block;
|
||||||
ResultSet resultSet = statement.executeQuery(query);
|
ResultSet resultSet = statement.executeQuery(query);
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
|
|
||||||
String owner = resultSet.getString("owner");
|
String owner = resultSet.getString("owner");
|
||||||
if (owner != null && owner.length() > 1) {
|
if (owner != null && owner.length() > 1) {
|
||||||
|
|
||||||
PaperAdapter.ADAPTER.setSkullOwner(skull, owner);
|
PaperAdapter.ADAPTER.setSkullOwner(skull, owner);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String skin = resultSet.getString("skin");
|
String skin = resultSet.getString("skin");
|
||||||
if (owner != null && skin != null && skin.length() > 0) {
|
if (owner != null && skin != null && skin.length() > 0) {
|
||||||
|
|
||||||
PaperAdapter.ADAPTER.setSkullSkin(skull, skin);
|
PaperAdapter.ADAPTER.setSkullSkin(skull, skin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,69 +13,96 @@ import net.coreprotect.database.Database;
|
|||||||
public class UserStatement {
|
public class UserStatement {
|
||||||
|
|
||||||
private UserStatement() {
|
private UserStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int insert(Connection connection, String user) {
|
public static int insert(Connection connection, String user) {
|
||||||
|
|
||||||
int id = -1;
|
int id = -1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
int unixtimestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||||
|
|
||||||
PreparedStatement preparedStmt = null;
|
PreparedStatement preparedStmt = null;
|
||||||
if (Database.hasReturningKeys()) {
|
if (Database.hasReturningKeys()) {
|
||||||
|
|
||||||
preparedStmt = connection.prepareStatement(
|
preparedStmt = connection.prepareStatement(
|
||||||
"INSERT INTO " + ConfigHandler.prefix + "user (time, user) VALUES (?, ?) RETURNING rowid");
|
"INSERT INTO " + ConfigHandler.prefix + "user (time, user) VALUES (?, ?) RETURNING rowid");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
preparedStmt = connection.prepareStatement(
|
preparedStmt = connection.prepareStatement(
|
||||||
"INSERT INTO " + ConfigHandler.prefix + "user (time, user) VALUES (?, ?)",
|
"INSERT INTO " + ConfigHandler.prefix + "user (time, user) VALUES (?, ?)",
|
||||||
Statement.RETURN_GENERATED_KEYS);
|
Statement.RETURN_GENERATED_KEYS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preparedStmt.setInt(1, unixtimestamp);
|
preparedStmt.setInt(1, unixtimestamp);
|
||||||
preparedStmt.setString(2, user);
|
preparedStmt.setString(2, user);
|
||||||
|
|
||||||
if (Database.hasReturningKeys()) {
|
if (Database.hasReturningKeys()) {
|
||||||
|
|
||||||
ResultSet resultSet = preparedStmt.executeQuery();
|
ResultSet resultSet = preparedStmt.executeQuery();
|
||||||
resultSet.next();
|
resultSet.next();
|
||||||
id = resultSet.getInt(1);
|
id = resultSet.getInt(1);
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
preparedStmt.executeUpdate();
|
preparedStmt.executeUpdate();
|
||||||
ResultSet keys = preparedStmt.getGeneratedKeys();
|
ResultSet keys = preparedStmt.getGeneratedKeys();
|
||||||
keys.next();
|
keys.next();
|
||||||
id = keys.getInt(1);
|
id = keys.getInt(1);
|
||||||
keys.close();
|
keys.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getId(PreparedStatement preparedStatement, String user, boolean load) throws SQLException {
|
public static int getId(PreparedStatement preparedStatement, String user, boolean load) throws SQLException {
|
||||||
|
|
||||||
if (load && !ConfigHandler.playerIdCache.containsKey(user.toLowerCase(Locale.ROOT))) {
|
if (load && !ConfigHandler.playerIdCache.containsKey(user.toLowerCase(Locale.ROOT))) {
|
||||||
|
|
||||||
UserStatement.loadId(preparedStatement.getConnection(), user, null);
|
UserStatement.loadId(preparedStatement.getConnection(), user, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
return ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int loadId(Connection connection, String user, String uuid) {
|
public static int loadId(Connection connection, String user, String uuid) {
|
||||||
|
|
||||||
// generate if doesn't exist
|
// generate if doesn't exist
|
||||||
int id = -1;
|
int id = -1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String collate = "";
|
String collate = "";
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
|
||||||
collate = " COLLATE NOCASE";
|
collate = " COLLATE NOCASE";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String where = "user = ?" + collate;
|
String where = "user = ?" + collate;
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
|
|
||||||
where = where + " OR uuid = ?";
|
where = where + " OR uuid = ?";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String query = "SELECT rowid as id, uuid FROM " + ConfigHandler.prefix + "user WHERE " + where
|
String query = "SELECT rowid as id, uuid FROM " + ConfigHandler.prefix + "user WHERE " + where
|
||||||
@@ -84,67 +111,93 @@ public class UserStatement {
|
|||||||
preparedStmt.setString(1, user);
|
preparedStmt.setString(1, user);
|
||||||
|
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
|
|
||||||
preparedStmt.setString(2, uuid);
|
preparedStmt.setString(2, uuid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSet resultSet = preparedStmt.executeQuery();
|
ResultSet resultSet = preparedStmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
|
|
||||||
id = resultSet.getInt("id");
|
id = resultSet.getInt("id");
|
||||||
uuid = resultSet.getString("uuid");
|
uuid = resultSet.getString("uuid");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
|
|
||||||
id = insert(connection, user);
|
id = insert(connection, user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.playerIdCache.put(user.toLowerCase(Locale.ROOT), id);
|
ConfigHandler.playerIdCache.put(user.toLowerCase(Locale.ROOT), id);
|
||||||
ConfigHandler.playerIdCacheReversed.put(id, user);
|
ConfigHandler.playerIdCacheReversed.put(id, user);
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
|
|
||||||
ConfigHandler.uuidCache.put(user.toLowerCase(Locale.ROOT), uuid);
|
ConfigHandler.uuidCache.put(user.toLowerCase(Locale.ROOT), uuid);
|
||||||
ConfigHandler.uuidCacheReversed.put(uuid, user);
|
ConfigHandler.uuidCacheReversed.put(uuid, user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String loadName(Connection connection, int id) {
|
public static String loadName(Connection connection, int id) {
|
||||||
|
|
||||||
// generate if doesn't exist
|
// generate if doesn't exist
|
||||||
String user = "";
|
String user = "";
|
||||||
String uuid = null;
|
String uuid = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
String query =
|
String query = "SELECT user, uuid FROM " + ConfigHandler.prefix + "user WHERE rowid='" + id
|
||||||
"SELECT user, uuid FROM " + ConfigHandler.prefix + "user WHERE rowid='" + id + "' LIMIT 0, 1";
|
+ "' LIMIT 0, 1";
|
||||||
|
|
||||||
ResultSet resultSet = statement.executeQuery(query);
|
ResultSet resultSet = statement.executeQuery(query);
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
|
|
||||||
user = resultSet.getString("user");
|
user = resultSet.getString("user");
|
||||||
uuid = resultSet.getString("uuid");
|
uuid = resultSet.getString("uuid");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.length() == 0) {
|
if (user.length() == 0) {
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.playerIdCache.put(user.toLowerCase(Locale.ROOT), id);
|
ConfigHandler.playerIdCache.put(user.toLowerCase(Locale.ROOT), id);
|
||||||
ConfigHandler.playerIdCacheReversed.put(id, user);
|
ConfigHandler.playerIdCacheReversed.put(id, user);
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
|
|
||||||
ConfigHandler.uuidCache.put(user.toLowerCase(Locale.ROOT), uuid);
|
ConfigHandler.uuidCache.put(user.toLowerCase(Locale.ROOT), uuid);
|
||||||
ConfigHandler.uuidCacheReversed.put(uuid, user);
|
ConfigHandler.uuidCacheReversed.put(uuid, user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,20 +5,31 @@ import java.sql.PreparedStatement;
|
|||||||
public class WorldStatement {
|
public class WorldStatement {
|
||||||
|
|
||||||
private WorldStatement() {
|
private WorldStatement() {
|
||||||
|
|
||||||
throw new IllegalStateException("Database class");
|
throw new IllegalStateException("Database class");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void insert(PreparedStatement preparedStmt, int batchCount, int id, String world) {
|
public static void insert(PreparedStatement preparedStmt, int batchCount, int id, String world) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
preparedStmt.setInt(1, id);
|
preparedStmt.setInt(1, id);
|
||||||
preparedStmt.setString(2, world);
|
preparedStmt.setString(2, world);
|
||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
|
|
||||||
if (batchCount > 0 && batchCount % 1000 == 0) {
|
if (batchCount > 0 && batchCount % 1000 == 0) {
|
||||||
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,38 +11,55 @@ public class CoreProtectPreLogEvent extends Event implements Cancellable {
|
|||||||
private String user;
|
private String user;
|
||||||
|
|
||||||
public CoreProtectPreLogEvent(String user) {
|
public CoreProtectPreLogEvent(String user) {
|
||||||
|
|
||||||
super(true); // async
|
super(true); // async
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUser() {
|
public String getUser() {
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
|
|
||||||
this.cancelled = cancel;
|
this.cancelled = cancel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUser(String newUser) {
|
public void setUser(String newUser) {
|
||||||
|
|
||||||
if (newUser == null || newUser.isEmpty()) {
|
if (newUser == null || newUser.isEmpty()) {
|
||||||
|
|
||||||
throw new IllegalArgumentException("Invalid user");
|
throw new IllegalArgumentException("Invalid user");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.user = newUser;
|
this.user = newUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,16 +9,21 @@ import org.bukkit.command.CommandSender;
|
|||||||
public class Extensions {
|
public class Extensions {
|
||||||
|
|
||||||
public static void runDatabaseMigration(String command, CommandSender user, String[] argumentArray) {
|
public static void runDatabaseMigration(String command, CommandSender user, String[] argumentArray) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Class<?> patchClass = Class.forName("net.coreprotect.extensions.DatabaseMigration");
|
Class<?> patchClass = Class.forName("net.coreprotect.extensions.DatabaseMigration");
|
||||||
Method patchMethod = patchClass.getDeclaredMethod("runCommand", CommandSender.class, String[].class);
|
Method patchMethod = patchClass.getDeclaredMethod("runCommand", CommandSender.class, String[].class);
|
||||||
patchMethod.invoke(null, user, argumentArray);
|
patchMethod.invoke(null, user, argumentArray);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
// plugin not compiled with extension
|
// plugin not compiled with extension
|
||||||
Chat.sendMessage(
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
||||||
user,
|
+ Phrase.build(Phrase.COMMAND_NOT_FOUND, Color.WHITE, "/co " + command));
|
||||||
Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- "
|
|
||||||
+ Phrase.build(Phrase.COMMAND_NOT_FOUND, Color.WHITE, "/co " + command));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,26 +9,37 @@ public class Language {
|
|||||||
private static ConcurrentHashMap<Phrase, String> translatedPhrases = new ConcurrentHashMap<>();
|
private static ConcurrentHashMap<Phrase, String> translatedPhrases = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
protected static String getPhrase(Phrase phrase) {
|
protected static String getPhrase(Phrase phrase) {
|
||||||
|
|
||||||
return phrases.get(phrase);
|
return phrases.get(phrase);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getUserPhrase(Phrase phrase) {
|
protected static String getUserPhrase(Phrase phrase) {
|
||||||
|
|
||||||
return userPhrases.get(phrase);
|
return userPhrases.get(phrase);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getTranslatedPhrase(Phrase phrase) {
|
protected static String getTranslatedPhrase(Phrase phrase) {
|
||||||
|
|
||||||
return translatedPhrases.get(phrase);
|
return translatedPhrases.get(phrase);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void setUserPhrase(Phrase phrase, String value) {
|
protected static void setUserPhrase(Phrase phrase, String value) {
|
||||||
|
|
||||||
userPhrases.put(phrase, value);
|
userPhrases.put(phrase, value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void setTranslatedPhrase(Phrase phrase, String value) {
|
protected static void setTranslatedPhrase(Phrase phrase, String value) {
|
||||||
|
|
||||||
translatedPhrases.put(phrase, value);
|
translatedPhrases.put(phrase, value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadPhrases() {
|
public static void loadPhrases() {
|
||||||
|
|
||||||
phrases.put(Phrase.ACTION_NOT_SUPPORTED, "That action is not supported by the command.");
|
phrases.put(Phrase.ACTION_NOT_SUPPORTED, "That action is not supported by the command.");
|
||||||
phrases.put(Phrase.AMOUNT_BLOCK, "{0} {block|blocks}");
|
phrases.put(Phrase.AMOUNT_BLOCK, "{0} {block|blocks}");
|
||||||
phrases.put(Phrase.AMOUNT_CHUNK, "{0} {chunk|chunks}");
|
phrases.put(Phrase.AMOUNT_CHUNK, "{0} {chunk|chunks}");
|
||||||
@@ -65,8 +76,7 @@ public class Language {
|
|||||||
phrases.put(Phrase.GLOBAL_LOOKUP, "Don't specify a radius to do a global lookup.");
|
phrases.put(Phrase.GLOBAL_LOOKUP, "Don't specify a radius to do a global lookup.");
|
||||||
phrases.put(Phrase.GLOBAL_ROLLBACK, "Use \"{0}\" to do a global {rollback|restore}");
|
phrases.put(Phrase.GLOBAL_ROLLBACK, "Use \"{0}\" to do a global {rollback|restore}");
|
||||||
phrases.put(Phrase.HELP_ACTION_1, "Restrict the lookup to a certain action.");
|
phrases.put(Phrase.HELP_ACTION_1, "Restrict the lookup to a certain action.");
|
||||||
phrases.put(
|
phrases.put(Phrase.HELP_ACTION_2,
|
||||||
Phrase.HELP_ACTION_2,
|
|
||||||
"Examples: [a:block], [a:+block], [a:-block] [a:click], [a:container], [a:inventory], [a:item], [a:kill], [a:chat], [a:command], [a:sign], [a:session], [a:username]");
|
"Examples: [a:block], [a:+block], [a:-block] [a:click], [a:container], [a:inventory], [a:item], [a:kill], [a:chat], [a:command], [a:sign], [a:session], [a:username]");
|
||||||
phrases.put(Phrase.HELP_COMMAND, "Display more info for that command.");
|
phrases.put(Phrase.HELP_COMMAND, "Display more info for that command.");
|
||||||
phrases.put(Phrase.HELP_EXCLUDE_1, "Exclude blocks/users.");
|
phrases.put(Phrase.HELP_EXCLUDE_1, "Exclude blocks/users.");
|
||||||
@@ -96,8 +106,7 @@ public class Language {
|
|||||||
phrases.put(Phrase.HELP_PARAMS_6, "Include specific blocks/entities in the {lookup|rollback|restore}.");
|
phrases.put(Phrase.HELP_PARAMS_6, "Include specific blocks/entities in the {lookup|rollback|restore}.");
|
||||||
phrases.put(Phrase.HELP_PARAMS_7, "Exclude blocks/users from the {lookup|rollback|restore}.");
|
phrases.put(Phrase.HELP_PARAMS_7, "Exclude blocks/users from the {lookup|rollback|restore}.");
|
||||||
phrases.put(Phrase.HELP_PURGE_1, "Delete data older than specified time.");
|
phrases.put(Phrase.HELP_PURGE_1, "Delete data older than specified time.");
|
||||||
phrases.put(
|
phrases.put(Phrase.HELP_PURGE_2,
|
||||||
Phrase.HELP_PURGE_2,
|
|
||||||
"For example, \"{0}\" will delete all data older than one month, and only keep the last 30 days of data.");
|
"For example, \"{0}\" will delete all data older than one month, and only keep the last 30 days of data.");
|
||||||
phrases.put(Phrase.HELP_PURGE_COMMAND, "Delete old block data.");
|
phrases.put(Phrase.HELP_PURGE_COMMAND, "Delete old block data.");
|
||||||
phrases.put(Phrase.HELP_RADIUS_1, "Specify a radius area.");
|
phrases.put(Phrase.HELP_RADIUS_1, "Specify a radius area.");
|
||||||
@@ -243,5 +252,7 @@ public class Language {
|
|||||||
|
|
||||||
userPhrases.putAll(phrases);
|
userPhrases.putAll(phrases);
|
||||||
translatedPhrases.putAll(phrases);
|
translatedPhrases.putAll(phrases);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,308 +10,166 @@ import net.coreprotect.utility.Color;
|
|||||||
import net.coreprotect.utility.Util;
|
import net.coreprotect.utility.Util;
|
||||||
|
|
||||||
public enum Phrase {
|
public enum Phrase {
|
||||||
ACTION_NOT_SUPPORTED,
|
|
||||||
AMOUNT_BLOCK,
|
|
||||||
AMOUNT_CHUNK,
|
|
||||||
AMOUNT_ENTITY,
|
|
||||||
AMOUNT_ITEM,
|
|
||||||
API_TEST,
|
|
||||||
CACHE_ERROR,
|
|
||||||
CACHE_RELOAD,
|
|
||||||
CHECK_CONFIG,
|
|
||||||
COMMAND_CONSOLE,
|
|
||||||
COMMAND_NOT_FOUND,
|
|
||||||
COMMAND_THROTTLED,
|
|
||||||
CONSUMER_ERROR,
|
|
||||||
CONSUMER_TOGGLED,
|
|
||||||
CONTAINER_HEADER,
|
|
||||||
CPU_CORES,
|
|
||||||
DATABASE_BUSY,
|
|
||||||
DATABASE_INDEX_ERROR,
|
|
||||||
DATABASE_LOCKED_1,
|
|
||||||
DATABASE_LOCKED_2,
|
|
||||||
DATABASE_LOCKED_3,
|
|
||||||
DATABASE_LOCKED_4,
|
|
||||||
DATABASE_UNREACHABLE,
|
|
||||||
DEVELOPMENT_BRANCH,
|
|
||||||
DIRT_BLOCK,
|
|
||||||
DISABLE_SUCCESS,
|
|
||||||
DONATION_KEY_REQUIRED,
|
|
||||||
ENABLE_FAILED,
|
|
||||||
ENABLE_SUCCESS,
|
|
||||||
ENJOY_COREPROTECT,
|
|
||||||
FINISHING_CONVERSION,
|
|
||||||
FINISHING_LOGGING,
|
|
||||||
FIRST_VERSION,
|
|
||||||
GLOBAL_LOOKUP,
|
|
||||||
GLOBAL_ROLLBACK,
|
|
||||||
HELP_ACTION_1,
|
|
||||||
HELP_ACTION_2,
|
|
||||||
HELP_COMMAND,
|
|
||||||
HELP_EXCLUDE_1,
|
|
||||||
HELP_EXCLUDE_2,
|
|
||||||
HELP_HEADER,
|
|
||||||
HELP_INCLUDE_1,
|
|
||||||
HELP_INCLUDE_2,
|
|
||||||
HELP_INSPECT_1,
|
|
||||||
HELP_INSPECT_2,
|
|
||||||
HELP_INSPECT_3,
|
|
||||||
HELP_INSPECT_4,
|
|
||||||
HELP_INSPECT_5,
|
|
||||||
HELP_INSPECT_6,
|
|
||||||
HELP_INSPECT_7,
|
|
||||||
HELP_INSPECT_COMMAND,
|
|
||||||
HELP_LIST,
|
|
||||||
HELP_LOOKUP_1,
|
|
||||||
HELP_LOOKUP_2,
|
|
||||||
HELP_LOOKUP_COMMAND,
|
|
||||||
HELP_NO_INFO,
|
|
||||||
HELP_PARAMETER,
|
|
||||||
HELP_PARAMS_1,
|
|
||||||
HELP_PARAMS_2,
|
|
||||||
HELP_PARAMS_3,
|
|
||||||
HELP_PARAMS_4,
|
|
||||||
HELP_PARAMS_5,
|
|
||||||
HELP_PARAMS_6,
|
|
||||||
HELP_PARAMS_7,
|
|
||||||
HELP_PURGE_1,
|
|
||||||
HELP_PURGE_2,
|
|
||||||
HELP_PURGE_COMMAND,
|
|
||||||
HELP_RADIUS_1,
|
|
||||||
HELP_RADIUS_2,
|
|
||||||
HELP_RELOAD_COMMAND,
|
|
||||||
HELP_RESTORE_COMMAND,
|
|
||||||
HELP_ROLLBACK_COMMAND,
|
|
||||||
HELP_STATUS,
|
|
||||||
HELP_STATUS_COMMAND,
|
|
||||||
HELP_TELEPORT,
|
|
||||||
HELP_TIME_1,
|
|
||||||
HELP_TIME_2,
|
|
||||||
HELP_USER_1,
|
|
||||||
HELP_USER_2,
|
|
||||||
INCOMPATIBLE_ACTION,
|
|
||||||
INSPECTOR_ERROR,
|
|
||||||
INSPECTOR_TOGGLED,
|
|
||||||
INTEGRATION_ERROR,
|
|
||||||
INTEGRATION_SUCCESS,
|
|
||||||
INTEGRATION_VERSION,
|
|
||||||
INTERACTIONS_HEADER,
|
|
||||||
INVALID_ACTION,
|
|
||||||
INVALID_BRANCH_1,
|
|
||||||
INVALID_BRANCH_2,
|
|
||||||
INVALID_BRANCH_3,
|
|
||||||
INVALID_CONTAINER,
|
|
||||||
INVALID_DONATION_KEY,
|
|
||||||
INVALID_INCLUDE,
|
|
||||||
INVALID_INCLUDE_COMBO,
|
|
||||||
INVALID_RADIUS,
|
|
||||||
INVALID_SELECTION,
|
|
||||||
INVALID_USERNAME,
|
|
||||||
INVALID_WORLD,
|
|
||||||
LATEST_VERSION,
|
|
||||||
LINK_DISCORD,
|
|
||||||
LINK_DOWNLOAD,
|
|
||||||
LINK_PATREON,
|
|
||||||
LINK_WIKI_BLOCK,
|
|
||||||
LINK_WIKI_ENTITY,
|
|
||||||
LOGGING_ITEMS,
|
|
||||||
LOGGING_TIME_LIMIT,
|
|
||||||
LOOKUP_BLOCK,
|
|
||||||
LOOKUP_CONTAINER,
|
|
||||||
LOOKUP_HEADER,
|
|
||||||
LOOKUP_INTERACTION,
|
|
||||||
LOOKUP_ITEM,
|
|
||||||
LOOKUP_LOGIN,
|
|
||||||
LOOKUP_PAGE,
|
|
||||||
LOOKUP_PROJECTILE,
|
|
||||||
LOOKUP_ROWS_FOUND,
|
|
||||||
LOOKUP_SEARCHING,
|
|
||||||
LOOKUP_STORAGE,
|
|
||||||
LOOKUP_TIME,
|
|
||||||
LOOKUP_USERNAME,
|
|
||||||
MAXIMUM_RADIUS,
|
|
||||||
MISSING_ACTION_USER,
|
|
||||||
MISSING_LOOKUP_TIME,
|
|
||||||
MISSING_LOOKUP_USER,
|
|
||||||
MISSING_PARAMETERS,
|
|
||||||
MISSING_ROLLBACK_RADIUS,
|
|
||||||
MISSING_ROLLBACK_USER,
|
|
||||||
MYSQL_UNAVAILABLE,
|
|
||||||
NETWORK_CONNECTION,
|
|
||||||
NETWORK_TEST,
|
|
||||||
NO_DATA,
|
|
||||||
NO_DATA_LOCATION,
|
|
||||||
NO_PERMISSION,
|
|
||||||
NO_RESULTS,
|
|
||||||
NO_RESULTS_PAGE,
|
|
||||||
NO_ROLLBACK,
|
|
||||||
PATCH_INTERRUPTED,
|
|
||||||
PATCH_OUTDATED_1,
|
|
||||||
PATCH_OUTDATED_2,
|
|
||||||
PATCH_PROCESSING,
|
|
||||||
PATCH_SKIP_UPDATE,
|
|
||||||
PATCH_STARTED,
|
|
||||||
PATCH_SUCCESS,
|
|
||||||
PATCH_UPGRADING,
|
|
||||||
PLEASE_SELECT,
|
|
||||||
PREVIEW_CANCELLED,
|
|
||||||
PREVIEW_CANCELLING,
|
|
||||||
PREVIEW_IN_GAME,
|
|
||||||
PREVIEW_TRANSACTION,
|
|
||||||
PRIMARY_THREAD_ERROR,
|
|
||||||
PURGE_ABORTED,
|
|
||||||
PURGE_ERROR,
|
|
||||||
PURGE_FAILED,
|
|
||||||
PURGE_IN_PROGRESS,
|
|
||||||
PURGE_MINIMUM_TIME,
|
|
||||||
PURGE_NOTICE_1,
|
|
||||||
PURGE_NOTICE_2,
|
|
||||||
PURGE_OPTIMIZING,
|
|
||||||
PURGE_PROCESSING,
|
|
||||||
PURGE_REPAIRING,
|
|
||||||
PURGE_ROWS,
|
|
||||||
PURGE_STARTED,
|
|
||||||
PURGE_SUCCESS,
|
|
||||||
RAM_STATS,
|
|
||||||
RELOAD_STARTED,
|
|
||||||
RELOAD_SUCCESS,
|
|
||||||
ROLLBACK_ABORTED,
|
|
||||||
ROLLBACK_CHUNKS_FOUND,
|
|
||||||
ROLLBACK_CHUNKS_MODIFIED,
|
|
||||||
ROLLBACK_COMPLETED,
|
|
||||||
ROLLBACK_EXCLUDED_USERS,
|
|
||||||
ROLLBACK_INCLUDE,
|
|
||||||
ROLLBACK_IN_PROGRESS,
|
|
||||||
ROLLBACK_LENGTH,
|
|
||||||
ROLLBACK_MODIFIED,
|
|
||||||
ROLLBACK_RADIUS,
|
|
||||||
ROLLBACK_SELECTION,
|
|
||||||
ROLLBACK_STARTED,
|
|
||||||
ROLLBACK_TIME,
|
|
||||||
ROLLBACK_WORLD_ACTION,
|
|
||||||
SIGN_HEADER,
|
|
||||||
STATUS_CONSUMER,
|
|
||||||
STATUS_DATABASE,
|
|
||||||
STATUS_INTEGRATION,
|
|
||||||
STATUS_LICENSE,
|
|
||||||
STATUS_SYSTEM,
|
|
||||||
STATUS_VERSION,
|
|
||||||
TELEPORTED,
|
|
||||||
TELEPORTED_SAFETY,
|
|
||||||
TELEPORT_PLAYERS,
|
|
||||||
TIME_DAYS,
|
|
||||||
TIME_HOURS,
|
|
||||||
TIME_MINUTES,
|
|
||||||
TIME_SECONDS,
|
|
||||||
TIME_WEEKS,
|
|
||||||
UPDATE_ERROR,
|
|
||||||
UPDATE_HEADER,
|
|
||||||
UPDATE_NOTICE,
|
|
||||||
UPGRADE_IN_PROGRESS,
|
|
||||||
USER_NOT_FOUND,
|
|
||||||
USER_OFFLINE,
|
|
||||||
USING_MYSQL,
|
|
||||||
USING_SQLITE,
|
|
||||||
VALID_DONATION_KEY,
|
|
||||||
VERSION_NOTICE,
|
|
||||||
VERSION_INCOMPATIBLE,
|
|
||||||
VERSION_REQUIRED,
|
|
||||||
WORLD_NOT_FOUND;
|
|
||||||
|
|
||||||
private static final Set<Phrase> HEADERS = new HashSet<>(Arrays.asList(
|
ACTION_NOT_SUPPORTED, AMOUNT_BLOCK, AMOUNT_CHUNK, AMOUNT_ENTITY, AMOUNT_ITEM, API_TEST, CACHE_ERROR, CACHE_RELOAD,
|
||||||
Phrase.CONTAINER_HEADER,
|
CHECK_CONFIG, COMMAND_CONSOLE, COMMAND_NOT_FOUND, COMMAND_THROTTLED, CONSUMER_ERROR, CONSUMER_TOGGLED,
|
||||||
Phrase.HELP_HEADER,
|
CONTAINER_HEADER, CPU_CORES, DATABASE_BUSY, DATABASE_INDEX_ERROR, DATABASE_LOCKED_1, DATABASE_LOCKED_2,
|
||||||
Phrase.INTERACTIONS_HEADER,
|
DATABASE_LOCKED_3, DATABASE_LOCKED_4, DATABASE_UNREACHABLE, DEVELOPMENT_BRANCH, DIRT_BLOCK, DISABLE_SUCCESS,
|
||||||
Phrase.LOOKUP_HEADER,
|
DONATION_KEY_REQUIRED, ENABLE_FAILED, ENABLE_SUCCESS, ENJOY_COREPROTECT, FINISHING_CONVERSION, FINISHING_LOGGING,
|
||||||
Phrase.SIGN_HEADER,
|
FIRST_VERSION, GLOBAL_LOOKUP, GLOBAL_ROLLBACK, HELP_ACTION_1, HELP_ACTION_2, HELP_COMMAND, HELP_EXCLUDE_1,
|
||||||
Phrase.UPDATE_HEADER));
|
HELP_EXCLUDE_2, HELP_HEADER, HELP_INCLUDE_1, HELP_INCLUDE_2, HELP_INSPECT_1, HELP_INSPECT_2, HELP_INSPECT_3,
|
||||||
|
HELP_INSPECT_4, HELP_INSPECT_5, HELP_INSPECT_6, HELP_INSPECT_7, HELP_INSPECT_COMMAND, HELP_LIST, HELP_LOOKUP_1,
|
||||||
|
HELP_LOOKUP_2, HELP_LOOKUP_COMMAND, HELP_NO_INFO, HELP_PARAMETER, HELP_PARAMS_1, HELP_PARAMS_2, HELP_PARAMS_3,
|
||||||
|
HELP_PARAMS_4, HELP_PARAMS_5, HELP_PARAMS_6, HELP_PARAMS_7, HELP_PURGE_1, HELP_PURGE_2, HELP_PURGE_COMMAND,
|
||||||
|
HELP_RADIUS_1, HELP_RADIUS_2, HELP_RELOAD_COMMAND, HELP_RESTORE_COMMAND, HELP_ROLLBACK_COMMAND, HELP_STATUS,
|
||||||
|
HELP_STATUS_COMMAND, HELP_TELEPORT, HELP_TIME_1, HELP_TIME_2, HELP_USER_1, HELP_USER_2, INCOMPATIBLE_ACTION,
|
||||||
|
INSPECTOR_ERROR, INSPECTOR_TOGGLED, INTEGRATION_ERROR, INTEGRATION_SUCCESS, INTEGRATION_VERSION,
|
||||||
|
INTERACTIONS_HEADER, INVALID_ACTION, INVALID_BRANCH_1, INVALID_BRANCH_2, INVALID_BRANCH_3, INVALID_CONTAINER,
|
||||||
|
INVALID_DONATION_KEY, INVALID_INCLUDE, INVALID_INCLUDE_COMBO, INVALID_RADIUS, INVALID_SELECTION, INVALID_USERNAME,
|
||||||
|
INVALID_WORLD, LATEST_VERSION, LINK_DISCORD, LINK_DOWNLOAD, LINK_PATREON, LINK_WIKI_BLOCK, LINK_WIKI_ENTITY,
|
||||||
|
LOGGING_ITEMS, LOGGING_TIME_LIMIT, LOOKUP_BLOCK, LOOKUP_CONTAINER, LOOKUP_HEADER, LOOKUP_INTERACTION, LOOKUP_ITEM,
|
||||||
|
LOOKUP_LOGIN, LOOKUP_PAGE, LOOKUP_PROJECTILE, LOOKUP_ROWS_FOUND, LOOKUP_SEARCHING, LOOKUP_STORAGE, LOOKUP_TIME,
|
||||||
|
LOOKUP_USERNAME, MAXIMUM_RADIUS, MISSING_ACTION_USER, MISSING_LOOKUP_TIME, MISSING_LOOKUP_USER, MISSING_PARAMETERS,
|
||||||
|
MISSING_ROLLBACK_RADIUS, MISSING_ROLLBACK_USER, MYSQL_UNAVAILABLE, NETWORK_CONNECTION, NETWORK_TEST, NO_DATA,
|
||||||
|
NO_DATA_LOCATION, NO_PERMISSION, NO_RESULTS, NO_RESULTS_PAGE, NO_ROLLBACK, PATCH_INTERRUPTED, PATCH_OUTDATED_1,
|
||||||
|
PATCH_OUTDATED_2, PATCH_PROCESSING, PATCH_SKIP_UPDATE, PATCH_STARTED, PATCH_SUCCESS, PATCH_UPGRADING, PLEASE_SELECT,
|
||||||
|
PREVIEW_CANCELLED, PREVIEW_CANCELLING, PREVIEW_IN_GAME, PREVIEW_TRANSACTION, PRIMARY_THREAD_ERROR, PURGE_ABORTED,
|
||||||
|
PURGE_ERROR, PURGE_FAILED, PURGE_IN_PROGRESS, PURGE_MINIMUM_TIME, PURGE_NOTICE_1, PURGE_NOTICE_2, PURGE_OPTIMIZING,
|
||||||
|
PURGE_PROCESSING, PURGE_REPAIRING, PURGE_ROWS, PURGE_STARTED, PURGE_SUCCESS, RAM_STATS, RELOAD_STARTED,
|
||||||
|
RELOAD_SUCCESS, ROLLBACK_ABORTED, ROLLBACK_CHUNKS_FOUND, ROLLBACK_CHUNKS_MODIFIED, ROLLBACK_COMPLETED,
|
||||||
|
ROLLBACK_EXCLUDED_USERS, ROLLBACK_INCLUDE, ROLLBACK_IN_PROGRESS, ROLLBACK_LENGTH, ROLLBACK_MODIFIED,
|
||||||
|
ROLLBACK_RADIUS, ROLLBACK_SELECTION, ROLLBACK_STARTED, ROLLBACK_TIME, ROLLBACK_WORLD_ACTION, SIGN_HEADER,
|
||||||
|
STATUS_CONSUMER, STATUS_DATABASE, STATUS_INTEGRATION, STATUS_LICENSE, STATUS_SYSTEM, STATUS_VERSION, TELEPORTED,
|
||||||
|
TELEPORTED_SAFETY, TELEPORT_PLAYERS, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS, TIME_WEEKS, UPDATE_ERROR,
|
||||||
|
UPDATE_HEADER, UPDATE_NOTICE, UPGRADE_IN_PROGRESS, USER_NOT_FOUND, USER_OFFLINE, USING_MYSQL, USING_SQLITE,
|
||||||
|
VALID_DONATION_KEY, VERSION_NOTICE, VERSION_INCOMPATIBLE, VERSION_REQUIRED, WORLD_NOT_FOUND;
|
||||||
|
|
||||||
|
private static final Set<Phrase> HEADERS = new HashSet<>(Arrays.asList(Phrase.CONTAINER_HEADER, Phrase.HELP_HEADER,
|
||||||
|
Phrase.INTERACTIONS_HEADER, Phrase.LOOKUP_HEADER, Phrase.SIGN_HEADER, Phrase.UPDATE_HEADER));
|
||||||
private static final Set<String> COLORS = new HashSet<>(Arrays.asList(Color.WHITE, Color.DARK_AQUA));
|
private static final Set<String> COLORS = new HashSet<>(Arrays.asList(Color.WHITE, Color.DARK_AQUA));
|
||||||
private static final String SPLIT = ":";
|
private static final String SPLIT = ":";
|
||||||
private static final String FULL_WIDTH_SPLIT = ":";
|
private static final String FULL_WIDTH_SPLIT = ":";
|
||||||
|
|
||||||
public String getPhrase() {
|
public String getPhrase() {
|
||||||
|
|
||||||
return Language.getPhrase(this);
|
return Language.getPhrase(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserPhrase() {
|
public String getUserPhrase() {
|
||||||
|
|
||||||
return Language.getUserPhrase(this);
|
return Language.getUserPhrase(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTranslatedPhrase() {
|
public String getTranslatedPhrase() {
|
||||||
|
|
||||||
return Language.getTranslatedPhrase(this);
|
return Language.getTranslatedPhrase(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String build(Phrase phrase, String... params) {
|
public static String build(Phrase phrase, String... params) {
|
||||||
|
|
||||||
String output = phrase.getTranslatedPhrase();
|
String output = phrase.getTranslatedPhrase();
|
||||||
String color = "";
|
String color = "";
|
||||||
|
|
||||||
if (HEADERS.contains(phrase)) {
|
if (HEADERS.contains(phrase)) {
|
||||||
|
|
||||||
output = Util.capitalize(output, true);
|
output = Util.capitalize(output, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int indexExtra = 0;
|
int indexExtra = 0;
|
||||||
for (String param : params) {
|
for (String param : params) {
|
||||||
|
|
||||||
if (index == 0 && COLORS.contains(param)) {
|
if (index == 0 && COLORS.contains(param)) {
|
||||||
|
|
||||||
color = param;
|
color = param;
|
||||||
indexExtra++;
|
indexExtra++;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Selector.SELECTORS.contains(param)) {
|
if (Selector.SELECTORS.contains(param)) {
|
||||||
|
|
||||||
output = Selector.processSelection(output, param, color);
|
output = Selector.processSelection(output, param, color);
|
||||||
indexExtra++;
|
indexExtra++;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output.contains("{" + index + "}")) {
|
if (output.contains("{" + index + "}")) {
|
||||||
|
|
||||||
output = output.replace("{" + index + "}", param);
|
output = output.replace("{" + index + "}", param);
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((index + indexExtra) != params.length) { // fallback for issues with user modified phrases
|
if ((index + indexExtra) != params.length) { // fallback for issues with user modified phrases
|
||||||
|
|
||||||
output = buildInternal(phrase, params, color);
|
output = buildInternal(phrase, params, color);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color.length() > 0) {
|
if (color.length() > 0) {
|
||||||
|
|
||||||
output = output.replaceFirst(SPLIT, SPLIT + color);
|
output = output.replaceFirst(SPLIT, SPLIT + color);
|
||||||
output = output.replaceFirst(FULL_WIDTH_SPLIT, FULL_WIDTH_SPLIT + color);
|
output = output.replaceFirst(FULL_WIDTH_SPLIT, FULL_WIDTH_SPLIT + color);
|
||||||
output = ChatMessage.parseQuotes(output, color);
|
output = ChatMessage.parseQuotes(output, color);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String buildInternal(Phrase phrase, String[] params, String color) {
|
private static String buildInternal(Phrase phrase, String[] params, String color) {
|
||||||
|
|
||||||
String output = phrase.getPhrase(); // get internal phrase
|
String output = phrase.getPhrase(); // get internal phrase
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (String param : params) {
|
for (String param : params) {
|
||||||
|
|
||||||
if (index == 0 && COLORS.contains(param)) {
|
if (index == 0 && COLORS.contains(param)) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Selector.SELECTORS.contains(param)) {
|
if (Selector.SELECTORS.contains(param)) {
|
||||||
|
|
||||||
output = Selector.processSelection(output, param, color);
|
output = Selector.processSelection(output, param, color);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output = output.replace("{" + index + "}", param);
|
output = output.replace("{" + index + "}", param);
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPhraseSelector(Phrase phrase, String selector) {
|
public static String getPhraseSelector(Phrase phrase, String selector) {
|
||||||
|
|
||||||
String translatedPhrase = phrase.getTranslatedPhrase();
|
String translatedPhrase = phrase.getTranslatedPhrase();
|
||||||
Pattern phrasePattern = Pattern.compile("(\\{[a-zA-Z| ]+})");
|
Pattern phrasePattern = Pattern.compile("(\\{[a-zA-Z| ]+})");
|
||||||
Matcher patternMatch = phrasePattern.matcher(translatedPhrase);
|
Matcher patternMatch = phrasePattern.matcher(translatedPhrase);
|
||||||
String match = "";
|
String match = "";
|
||||||
if (patternMatch.find()) {
|
if (patternMatch.find()) {
|
||||||
|
|
||||||
match = patternMatch.group(1);
|
match = patternMatch.group(1);
|
||||||
match = Selector.processSelection(match, selector, "");
|
match = Selector.processSelection(match, selector, "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return match;
|
return match;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loaded 100 of 200 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user