Update gradle to 8.14.3
This commit is contained in:
1 parent
bff2281a35
commit
cf57e019cb
43 files changed
+8125
-3376
No files matched your search
+96
-56
@@ -1,84 +1,124 @@
|
||||
/* ------------------------------ Plugins ------------------------------ */
|
||||
plugins {
|
||||
id("java")
|
||||
id("java-library")
|
||||
id("com.diffplug.spotless") version "7.0.4"
|
||||
id("com.gradleup.shadow") version "8.3.6"
|
||||
eclipse
|
||||
id("java") // Import Java plugin.
|
||||
id("java-library") // Import Java Library plugin.
|
||||
id("com.diffplug.spotless") version "7.0.4" // Import Spotless plugin.
|
||||
id("com.gradleup.shadow") version "8.3.6" // Import Shadow plugin.
|
||||
id("checkstyle") // Import Checkstyle plugin.
|
||||
eclipse // Import Eclipse plugin.
|
||||
kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin.
|
||||
}
|
||||
|
||||
/* --------------------------- JDK / Kotlin ---------------------------- */
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
|
||||
toolchain { // Select Java toolchain.
|
||||
languageVersion.set(JavaLanguageVersion.of(17)) // Use JDK 17.
|
||||
vendor.set(JvmVendorSpec.GRAAL_VM) // Use GraalVM CE.
|
||||
}
|
||||
}
|
||||
|
||||
kotlin { jvmToolchain(17) }
|
||||
|
||||
/* ----------------------------- Metadata ------------------------------ */
|
||||
|
||||
version = "2.9.13" // Declare plugin version (will be in .jar).
|
||||
|
||||
group = "net.trueog.illegalstack-og" // Declare bundle identifier.
|
||||
|
||||
val apiVersion = "1.19" // Declare minecraft server target version.
|
||||
|
||||
/* ----------------------------- Resources ----------------------------- */
|
||||
tasks.named<ProcessResources>("processResources") {
|
||||
val props = mapOf("version" to version, "apiVersion" to apiVersion)
|
||||
inputs.properties(props) // Indicates to rerun if version changes.
|
||||
filesMatching("plugin.yml") { expand(props) }
|
||||
from("LICENSE") { into("/") } // Bundle licenses into jarfiles.
|
||||
}
|
||||
|
||||
/* ---------------------------- Repos ---------------------------------- */
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
mavenCentral() // Import the Maven Central Maven Repository.
|
||||
gradlePluginPortal() // Import the Gradle Plugin Portal Maven Repository.
|
||||
maven {
|
||||
name = "OSS Sonatype"
|
||||
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
|
||||
}
|
||||
} // Import the OSS Sonatype Maven Repository.
|
||||
maven { url = uri("https://repo.papermc.io/repository/maven-public/") } // Import the PaperMC Maven Repository.
|
||||
maven {
|
||||
name = "PaperMC"
|
||||
url = uri("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
maven {
|
||||
name = "ProtocolLib"
|
||||
url = uri("https://repo.dmulloy2.net/nexus/repository/public/")
|
||||
}
|
||||
maven {
|
||||
name = "Magic"
|
||||
url = uri("https://maven.elmakers.com/repository/")
|
||||
}
|
||||
maven {
|
||||
name = "CodeMC"
|
||||
url = uri("https://repo.codemc.org/repository/maven-public/")
|
||||
}
|
||||
maven {
|
||||
name = "JitPack"
|
||||
url = uri("https://jitpack.io")
|
||||
}
|
||||
} // Import the ProtocolLib Maven Repository.
|
||||
maven { url = uri("https://maven.elmakers.com/repository/") } // Import the Magic plugin Maven Repository.
|
||||
maven { url = uri("https://repo.codemc.org/repository/maven-public/") } // Import the CodeMC Maven Repository.
|
||||
maven { url = uri("https://jitpack.io") } // Import the Jitpack Maven Repository.
|
||||
}
|
||||
|
||||
/* ---------------------- Java project deps ---------------------------- */
|
||||
dependencies {
|
||||
compileOnly("dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
|
||||
compileOnly("com.elmakers.mine.bukkit:MagicAPI:10.2")
|
||||
compileOnly("de.tr7zw:item-nbt-api-plugin:2.8.0")
|
||||
compileOnly("com.github.TheBusyBiscuit:Slimefun4:RC-30") { isTransitive = false }
|
||||
compileOnly("io.netty:netty-all:4.1.110.Final") {
|
||||
compileOnly("dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT") // Declare Folia API to be packaged.
|
||||
compileOnly(files("libs/ProtocolLib-5.0.jar")) // Import Legacy ProtocolLib API.
|
||||
compileOnly("com.elmakers.mine.bukkit:MagicAPI:10.2") // Import Magic API.
|
||||
compileOnly("de.tr7zw:item-nbt-api-plugin:2.8.0") // Import Item NBT API.
|
||||
compileOnly("com.github.TheBusyBiscuit:Slimefun4:RC-30") { isTransitive = false } // Import SlimeFun4.
|
||||
compileOnly("io.netty:netty-all:4.1.110.Final") { // Import netty API.
|
||||
because(
|
||||
"The version aligns with the version used by Minecraft itself." +
|
||||
"The minecraft server ships netty as well, so we don't need to include it in the jar."
|
||||
)
|
||||
}
|
||||
compileOnly("com.gmail.nossr50.mcMMO:mcMMO:2.1.217") { isTransitive = false }
|
||||
compileOnly("fr.minuskube.inv:smart-invs:1.2.7")
|
||||
compileOnly("com.github.brcdev-minecraft:shopgui-api:3.0.0")
|
||||
compileOnly("com.gmail.nossr50.mcMMO:mcMMO:2.1.217") { isTransitive = false } // Import mcMMO API.
|
||||
compileOnly("fr.minuskube.inv:smart-invs:1.2.7") // Import SmartInvs API.
|
||||
compileOnly("com.github.brcdev-minecraft:shopgui-api:3.0.0") // Import ShopGUI API.
|
||||
}
|
||||
|
||||
the<JavaPluginExtension>().toolchain { languageVersion.set(JavaLanguageVersion.of(17)) }
|
||||
|
||||
configurations.all { attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17) }
|
||||
|
||||
tasks.build {
|
||||
dependsOn(tasks.spotlessApply)
|
||||
dependsOn(tasks.shadowJar)
|
||||
/* ---------------------- Reproducible jars ---------------------------- */
|
||||
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .jars
|
||||
isPreserveFileTimestamps = false
|
||||
isReproducibleFileOrder = true
|
||||
}
|
||||
|
||||
tasks.compileJava.configure { options.release.set(17) }
|
||||
|
||||
version = "2.9.13"
|
||||
|
||||
val pluginVersion = version.toString()
|
||||
|
||||
tasks.named<Copy>("processResources") {
|
||||
inputs.property("version", pluginVersion)
|
||||
filesMatching("plugin.yml") { expand(mapOf("version" to pluginVersion)) }
|
||||
/* ----------------------------- Shadow -------------------------------- */
|
||||
tasks.shadowJar {
|
||||
exclude("io.github.miniplaceholders.*") // Exclude the MiniPlaceholders package from being shadowed.
|
||||
archiveClassifier.set("") // Use empty string instead of null.
|
||||
minimize()
|
||||
}
|
||||
|
||||
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
|
||||
|
||||
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) } // Build depends on spotless and shadow.
|
||||
|
||||
/* --------------------------- Javac opts ------------------------------- */
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add("-parameters") // Enable reflection for java code.
|
||||
options.isFork = true // Run javac in its own process.
|
||||
options.compilerArgs.add("-Xlint:deprecation") // Trigger deprecation warning messages.
|
||||
options.encoding = "UTF-8" // Use UTF-8 file encoding.
|
||||
}
|
||||
|
||||
/* ----------------------------- Auto Formatting ------------------------ */
|
||||
spotless {
|
||||
java {
|
||||
removeUnusedImports()
|
||||
palantirJavaFormat()
|
||||
eclipse().configFile("config/formatter/eclipse-java-formatter.xml") // Eclipse java formatting.
|
||||
leadingTabsToSpaces() // Convert leftover leading tabs to spaces.
|
||||
removeUnusedImports() // Remove imports that aren't being called.
|
||||
}
|
||||
kotlinGradle {
|
||||
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) }
|
||||
target("build.gradle.kts", "settings.gradle.kts")
|
||||
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } // JetBrains Kotlin formatting.
|
||||
target("build.gradle.kts", "settings.gradle.kts") // Gradle files to format.
|
||||
}
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.18.1" // Declare checkstyle version to use.
|
||||
configFile = file("config/checkstyle/checkstyle.xml") // Point checkstyle to config file.
|
||||
isIgnoreFailures = true // Don't fail the build if checkstyle does not pass.
|
||||
isShowViolations = true // Show the violations in any IDE with the checkstyle plugin.
|
||||
}
|
||||
|
||||
tasks.named("compileJava") {
|
||||
dependsOn("spotlessApply") // Run spotless before compiling with the JDK.
|
||||
}
|
||||
|
||||
tasks.named("spotlessCheck") {
|
||||
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
|
||||
}
|
||||
@@ -0,0 +1,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>
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
@@ -11,50 +11,64 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class IllegalStackAction {
|
||||
|
||||
public static boolean isCompleted(
|
||||
Protections protection,
|
||||
Entity cause,
|
||||
Block block,
|
||||
ItemStack itemInHand,
|
||||
Entity mount,
|
||||
Inventory inventory) {
|
||||
IllegalStackActionEvent event =
|
||||
new IllegalStackActionEvent(protection, cause, block, itemInHand, mount, inventory);
|
||||
public static boolean isCompleted(Protections protection, Entity cause, Block block, ItemStack itemInHand,
|
||||
Entity mount, Inventory inventory)
|
||||
{
|
||||
|
||||
IllegalStackActionEvent event = new IllegalStackActionEvent(protection, cause, block, itemInHand, mount,
|
||||
inventory);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
return !event.isCancelled();
|
||||
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Entity entity, Player player) {
|
||||
|
||||
return isCompleted(protection, player, null, null, entity, null);
|
||||
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Player player, Block block) {
|
||||
|
||||
return isCompleted(protection, player, block, null, null, null);
|
||||
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Player player, Block block, ItemStack itemInHand) {
|
||||
|
||||
return isCompleted(protection, player, block, itemInHand, null, null);
|
||||
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Player player) {
|
||||
|
||||
return isCompleted(protection, player, null, null, null, null);
|
||||
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Entity entity, Player player, Block block) {
|
||||
|
||||
return isCompleted(protection, player, block, null, entity, null);
|
||||
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Entity entity, Entity mount) {
|
||||
|
||||
return isCompleted(protection, entity, null, null, mount, null);
|
||||
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, ItemStack item, Block block) {
|
||||
|
||||
return isCompleted(protection, null, block, item, null, null);
|
||||
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, ItemStack item, Inventory inventory) {
|
||||
|
||||
return isCompleted(protection, null, null, item, null, inventory);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,74 +19,98 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
public class BadAttributeCheck {
|
||||
|
||||
public static void CheckStorageInventory(CraftingInventory inventory, Player player) {
|
||||
|
||||
if (Protections.RemoveCustomAttributes.isEnabled(inventory) && IllegalStack.hasStorage()) {
|
||||
|
||||
if (Protections.AllowBypass.isEnabled() && player.hasPermission("illegalstack.enchantbypass")) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
for (ItemStack itemStack : inventory.getStorageContents()) {
|
||||
|
||||
if (itemStack != null && itemStack.getType() != Material.AIR && NBTStuff.hasBadCustomData(itemStack)) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append2(Msg.GenericItemRemoval.getValue(
|
||||
itemStack, Protections.RemoveCustomAttributes, player, "Crafting Inventory"));
|
||||
|
||||
fListener.getLog().append2(Msg.GenericItemRemoval.getValue(itemStack,
|
||||
Protections.RemoveCustomAttributes, player, "Crafting Inventory"));
|
||||
|
||||
inventory.removeItem(itemStack);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasBadAttributes(ItemStack is, Object obj) {
|
||||
|
||||
if (!Protections.RemoveCustomAttributes.isEnabled(obj)) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return is != null && is.getType() != Material.AIR && checkForBadCustomData(is, obj);
|
||||
|
||||
}
|
||||
|
||||
public static boolean checkForBadCustomData(ItemStack itemStack, Object obj) {
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (IllegalStack.isHasAttribAPI()) {
|
||||
|
||||
if (itemMeta.hasAttributeModifiers()) {
|
||||
|
||||
StringBuilder attribs = new StringBuilder();
|
||||
HashSet<Attribute> toRemove = new HashSet<>();
|
||||
for (Attribute a : itemMeta.getAttributeModifiers().keySet()) {
|
||||
|
||||
for (AttributeModifier st : itemMeta.getAttributeModifiers(a)) {
|
||||
attribs.append(" ")
|
||||
.append(st.getName())
|
||||
.append(" value: ")
|
||||
.append(st.getAmount());
|
||||
|
||||
attribs.append(" ").append(st.getName()).append(" value: ").append(st.getAmount());
|
||||
|
||||
}
|
||||
|
||||
toRemove.add(a);
|
||||
|
||||
}
|
||||
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.CustomAttribsRemoved3.getValue(itemStack, obj, attribs),
|
||||
Protections.RemoveCustomAttributes);
|
||||
fListener.getLog().append(Msg.CustomAttribsRemoved3.getValue(itemStack, obj, attribs),
|
||||
Protections.RemoveCustomAttributes);
|
||||
|
||||
for (Attribute remove : toRemove) {
|
||||
|
||||
itemMeta.removeAttributeModifier(remove);
|
||||
|
||||
}
|
||||
|
||||
for (ItemFlag iFlag : itemMeta.getItemFlags()) {
|
||||
|
||||
itemMeta.removeItemFlags(iFlag);
|
||||
|
||||
}
|
||||
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
|
||||
return NBTApiStuff.checkForBadCustomDataLegacy(itemStack, obj);
|
||||
|
||||
} else {
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.StaffNoNBTAPI.getValue(Protections.RemoveCustomAttributes.name()),
|
||||
Protections.RemoveCustomAttributes);
|
||||
|
||||
fListener.getLog().append(Msg.StaffNoNBTAPI.getValue(Protections.RemoveCustomAttributes.name()),
|
||||
Protections.RemoveCustomAttributes);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,85 +19,95 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class BadPotionCheck {
|
||||
|
||||
public static void checkPotion(ItemStack is, Player p) {
|
||||
if (!is.hasItemMeta()) return;
|
||||
|
||||
if (!is.hasItemMeta())
|
||||
return;
|
||||
ItemMeta im = is.getItemMeta();
|
||||
if (Protections.PreventInvalidPotions.isEnabled() && im instanceof PotionMeta) {
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass")) return;
|
||||
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass"))
|
||||
return;
|
||||
|
||||
if (IllegalStack.isHasMCMMO()
|
||||
&& NBTStuff.hasNbtTag("IllegalStack", is, "mcmmoitem", Protections.PreventInvalidPotions)) return;
|
||||
&& NBTStuff.hasNbtTag("IllegalStack", is, "mcmmoitem", Protections.PreventInvalidPotions))
|
||||
return;
|
||||
|
||||
PotionMeta potion = (PotionMeta) is.getItemMeta();
|
||||
PotionData pd = potion.getBasePotionData();
|
||||
if (pd.getType() == PotionType.UNCRAFTABLE
|
||||
|| (potion.hasCustomEffects() && !potion.getCustomEffects().isEmpty())) {
|
||||
|| (potion.hasCustomEffects() && !potion.getCustomEffects().isEmpty()))
|
||||
{
|
||||
|
||||
if (pd.getType() == PotionType.UNCRAFTABLE
|
||||
&& potion.getCustomEffects().isEmpty()) return;
|
||||
if (pd.getType() == PotionType.UNCRAFTABLE && potion.getCustomEffects().isEmpty())
|
||||
return;
|
||||
|
||||
p.getInventory().remove(is);
|
||||
StringBuilder efx = new StringBuilder();
|
||||
for (PotionEffect ce : potion.getCustomEffects()) {
|
||||
efx.append(ce.getType().getName())
|
||||
.append(" amplifier: ")
|
||||
.append(ce.getAmplifier())
|
||||
.append(" duration: ")
|
||||
.append(ce.getDuration())
|
||||
.append(",");
|
||||
|
||||
efx.append(ce.getType().getName()).append(" amplifier: ").append(ce.getAmplifier())
|
||||
.append(" duration: ").append(ce.getDuration()).append(",");
|
||||
|
||||
}
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.InvalidPotionRemoved.getValue(p, efx.toString()),
|
||||
Protections.PreventInvalidPotions);
|
||||
|
||||
fListener.getLog().append(Msg.InvalidPotionRemoved.getValue(p, efx.toString()),
|
||||
Protections.PreventInvalidPotions);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isInvalidPotion(@NotNull Projectile proj) {
|
||||
|
||||
if (proj instanceof ThrownPotion) {
|
||||
|
||||
ThrownPotion tp = (ThrownPotion) proj;
|
||||
Player p = null;
|
||||
if (proj.getShooter() instanceof Player) p = ((Player) proj.getShooter());
|
||||
if (proj.getShooter() instanceof Player)
|
||||
p = ((Player) proj.getShooter());
|
||||
|
||||
if (p != null && Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass"))
|
||||
return false;
|
||||
|
||||
PotionMeta potion = null;
|
||||
|
||||
if (IllegalStack.isPaperServer()) potion = (PotionMeta) tp.getPotionMeta();
|
||||
else potion = (PotionMeta) tp.getItem().getItemMeta();
|
||||
if (IllegalStack.isPaperServer())
|
||||
potion = (PotionMeta) tp.getPotionMeta();
|
||||
else
|
||||
potion = (PotionMeta) tp.getItem().getItemMeta();
|
||||
|
||||
PotionData pd = potion.getBasePotionData();
|
||||
|
||||
PotionType pt = null;
|
||||
|
||||
if (pd.getType() == PotionType.UNCRAFTABLE
|
||||
|| (potion.hasCustomEffects() && !potion.getCustomEffects().isEmpty())) {
|
||||
|| (potion.hasCustomEffects() && !potion.getCustomEffects().isEmpty()))
|
||||
{
|
||||
|
||||
if (pd.getType() == PotionType.UNCRAFTABLE
|
||||
&& potion.getCustomEffects().isEmpty()) return false;
|
||||
if (pd.getType() == PotionType.UNCRAFTABLE && potion.getCustomEffects().isEmpty())
|
||||
return false;
|
||||
|
||||
// p.getInventory().remove(is);
|
||||
StringBuilder efx = new StringBuilder();
|
||||
for (PotionEffect ce : potion.getCustomEffects()) {
|
||||
efx.append(ce.getType().getName())
|
||||
.append(" amplifier: ")
|
||||
.append(ce.getAmplifier())
|
||||
.append(" duration: ")
|
||||
.append(ce.getDuration())
|
||||
.append(",");
|
||||
|
||||
efx.append(ce.getType().getName()).append(" amplifier: ").append(ce.getAmplifier())
|
||||
.append(" duration: ").append(ce.getDuration()).append(",");
|
||||
|
||||
}
|
||||
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.InvalidThrownPotionRemoved.getValue(p, efx.toString()),
|
||||
Protections.PreventInvalidPotions);
|
||||
fListener.getLog().append(Msg.InvalidThrownPotionRemoved.getValue(p, efx.toString()),
|
||||
Protections.PreventInvalidPotions);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,123 +19,170 @@ import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
public class CheckUtils {
|
||||
|
||||
public static boolean CheckEntireContainer(Container container) {
|
||||
|
||||
boolean added = false;
|
||||
for (ItemStack itemStack : container.getInventory()) {
|
||||
if (itemStack != null
|
||||
&& IllegalStack.hasShulkers()
|
||||
&& itemStack.getType().name().contains("SHULKER_BOX")) {
|
||||
|
||||
if (itemStack != null && IllegalStack.hasShulkers() && itemStack.getType().name().contains("SHULKER_BOX")) {
|
||||
|
||||
int tagSize = NBTStuff.isBadShulker(itemStack);
|
||||
if (tagSize > 0
|
||||
&& IllegalStackAction.isCompleted(
|
||||
Protections.DestroyInvalidShulkers, itemStack, container.getInventory())) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.StaffBadShulkerRemoved.getValue(container.getLocation(), tagSize),
|
||||
Protections.DestroyInvalidShulkers);
|
||||
if (tagSize > 0 && IllegalStackAction.isCompleted(Protections.DestroyInvalidShulkers, itemStack,
|
||||
container.getInventory()))
|
||||
{
|
||||
|
||||
fListener.getLog().append(Msg.StaffBadShulkerRemoved.getValue(container.getLocation(), tagSize),
|
||||
Protections.DestroyInvalidShulkers);
|
||||
itemStack.setType(Material.AIR);
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
if (itemStack.getItemMeta() instanceof BlockStateMeta) {
|
||||
|
||||
BlockStateMeta im = (BlockStateMeta) itemStack.getItemMeta();
|
||||
boolean remove = false;
|
||||
if (im.getBlockState() instanceof ShulkerBox) {
|
||||
|
||||
BlockState shulk = im.getBlockState();
|
||||
ShulkerBox shulker = (ShulkerBox) shulk;
|
||||
Inventory inv = Bukkit.createInventory(
|
||||
null, shulker.getInventory().getSize(), "IScontainerCheck");
|
||||
Inventory inv = Bukkit.createInventory(null, shulker.getInventory().getSize(),
|
||||
"IScontainerCheck");
|
||||
for (ItemStack itemStack1 : shulker.getInventory().getContents()) {
|
||||
|
||||
if (itemStack1 == null) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
tagSize = NBTStuff.isBadShulker(itemStack1);
|
||||
if (tagSize > 0
|
||||
&& IllegalStackAction.isCompleted(
|
||||
Protections.DestroyInvalidShulkers,
|
||||
itemStack1,
|
||||
shulker.getInventory())) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.StaffBadShulkerRemoved.getValue(
|
||||
container.getLocation(), tagSize),
|
||||
Protections.DestroyInvalidShulkers);
|
||||
if (tagSize > 0 && IllegalStackAction.isCompleted(Protections.DestroyInvalidShulkers,
|
||||
itemStack1, shulker.getInventory()))
|
||||
{
|
||||
|
||||
fListener.getLog().append(
|
||||
Msg.StaffBadShulkerRemoved.getValue(container.getLocation(), tagSize),
|
||||
Protections.DestroyInvalidShulkers);
|
||||
itemStack1.setType(Material.AIR);
|
||||
remove = true;
|
||||
|
||||
}
|
||||
|
||||
if (!remove) {
|
||||
|
||||
remove = OverstackedItemCheck.CheckContainer(itemStack1, container);
|
||||
|
||||
}
|
||||
|
||||
if (!remove) {
|
||||
|
||||
remove = IllegalEnchantCheck.isIllegallyEnchanted(itemStack1, container);
|
||||
|
||||
}
|
||||
|
||||
if (!remove) {
|
||||
|
||||
remove = RemoveItemTypesCheck.shouldRemove(itemStack1, container);
|
||||
|
||||
}
|
||||
|
||||
if (remove) {
|
||||
|
||||
inv.removeItem(itemStack1);
|
||||
added = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (added) {
|
||||
Scheduler.runTaskLater(
|
||||
IllegalStack.getPlugin(),
|
||||
() -> {
|
||||
shulker.getInventory().setContents(inv.getContents());
|
||||
im.setBlockState(shulker);
|
||||
itemStack.setItemMeta(im);
|
||||
},
|
||||
4,
|
||||
shulker.getLocation());
|
||||
|
||||
Scheduler.runTaskLater(IllegalStack.getPlugin(), () -> {
|
||||
|
||||
shulker.getInventory().setContents(inv.getContents());
|
||||
im.setBlockState(shulker);
|
||||
itemStack.setItemMeta(im);
|
||||
|
||||
}, 4, shulker.getLocation());
|
||||
return true;
|
||||
// shulk.update(true);
|
||||
// shulk.setBlockData(shulker.getBlockData());
|
||||
// im.setBlockState(shulk);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (OverstackedItemCheck.CheckContainer(itemStack, container)) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (IllegalEnchantCheck.isIllegallyEnchanted(itemStack, container)) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckEntireInventory(Inventory inv) {
|
||||
|
||||
for (ItemStack is : inv.getContents()) {
|
||||
|
||||
if (is == null) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (RemoveItemTypesCheck.shouldRemove(is, inv)) {
|
||||
|
||||
return true;
|
||||
|
||||
} else if (IllegalEnchantCheck.isIllegallyEnchanted(is, inv)) {
|
||||
|
||||
return true;
|
||||
|
||||
} else if (BadAttributeCheck.hasBadAttributes(is, inv)) {
|
||||
|
||||
return true;
|
||||
|
||||
} else if (OverstackedItemCheck.CheckContainer(is, inv)) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!fListener.is18() && IllegalStack.hasStorage()) {
|
||||
|
||||
for (ItemStack is : inv.getStorageContents()) {
|
||||
|
||||
if (OverstackedItemCheck.CheckContainer(is, inv)) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,132 +19,195 @@ public class IllegalEnchantCheck {
|
||||
public static boolean CheckForIllegalEnchants(ItemStack itemStack, Object obj) {
|
||||
|
||||
if (itemStack != null && (obj instanceof Inventory || obj instanceof Container)) {
|
||||
|
||||
return isIllegallyEnchanted(itemStack, obj);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckStorageInventory(Inventory inv, Player player) {
|
||||
|
||||
if (!IllegalStack.hasStorage()) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
boolean invalid = false;
|
||||
for (ItemStack itemStack : inv.getStorageContents()) {
|
||||
if (itemStack != null
|
||||
&& itemStack.getType() != Material.AIR
|
||||
&& (invalid = isIllegallyEnchanted(itemStack, inv, true))) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append2(Msg.GenericItemRemoval.getValue(
|
||||
itemStack, Protections.FixIllegalEnchantmentLevels, player, "Crafting Inventory"));
|
||||
|
||||
if (itemStack != null && itemStack.getType() != Material.AIR
|
||||
&& (invalid = isIllegallyEnchanted(itemStack, inv, true)))
|
||||
{
|
||||
|
||||
fListener.getLog().append2(Msg.GenericItemRemoval.getValue(itemStack,
|
||||
Protections.FixIllegalEnchantmentLevels, player, "Crafting Inventory"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return invalid;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isIllegallyEnchanted(ItemStack itemStack, Object obj) {
|
||||
|
||||
return isIllegallyEnchanted(itemStack, obj, false);
|
||||
|
||||
}
|
||||
|
||||
public static boolean isIllegallyEnchanted(ItemStack itemStack, Object obj, boolean silent) {
|
||||
|
||||
if (itemStack == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled(obj)
|
||||
&& !itemStack.getEnchantments().isEmpty()) {
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled(obj) && !itemStack.getEnchantments().isEmpty()) {
|
||||
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().isEmpty()) { // world list isnt empty
|
||||
|
||||
Location loc = null;
|
||||
|
||||
if (obj instanceof Inventory) {
|
||||
|
||||
loc = ((Inventory) obj).getLocation();
|
||||
|
||||
} else if (obj instanceof Location) {
|
||||
|
||||
loc = ((Location) obj);
|
||||
|
||||
} else if (obj instanceof Container) {
|
||||
|
||||
loc = ((Container) obj).getLocation();
|
||||
|
||||
}
|
||||
|
||||
if (loc != null
|
||||
&& !Protections.OnlyFunctionInWorlds.getTxtSet()
|
||||
.contains(loc.getWorld().getName())) // isnt in a checked world
|
||||
if (loc != null && !Protections.OnlyFunctionInWorlds.getTxtSet().contains(loc.getWorld().getName())) // isnt
|
||||
// in
|
||||
// a
|
||||
// checked
|
||||
// world
|
||||
{
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HashSet<Enchantment> replace = new HashSet<>();
|
||||
for (Enchantment enchantment : itemStack.getEnchantments().keySet()) {
|
||||
|
||||
if (itemStack.getEnchantmentLevel(enchantment) > enchantment.getMaxLevel()) {
|
||||
|
||||
if (SlimefunCompat.isValid(itemStack, enchantment)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (IllegalStack.isEpicRename()
|
||||
&& ((enchantment == Enchantment.LURE || enchantment == Enchantment.ARROW_INFINITE)
|
||||
&& itemStack.getEnchantmentLevel(enchantment) == 4341)) {
|
||||
&& itemStack.getEnchantmentLevel(enchantment) == 4341))
|
||||
{
|
||||
|
||||
continue;
|
||||
}
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(itemStack)) {
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(
|
||||
enchantment, itemStack.getEnchantmentLevel(enchantment))) {
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(itemStack)) {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(enchantment,
|
||||
itemStack.getEnchantmentLevel(enchantment)))
|
||||
{
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (Protections.DestroyIllegallyEnchantedItemsInstead.isEnabled(obj)) {
|
||||
|
||||
if (!silent) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.DestroyedEnchantedItem.getValue(obj, itemStack, enchantment),
|
||||
Protections.DestroyIllegallyEnchantedItemsInstead);
|
||||
|
||||
fListener.getLog().append(Msg.DestroyedEnchantedItem.getValue(obj, itemStack, enchantment),
|
||||
Protections.DestroyIllegallyEnchantedItemsInstead);
|
||||
|
||||
}
|
||||
|
||||
itemStack.setType(Material.AIR);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (enchantment.canEnchantItem(itemStack)) {
|
||||
|
||||
if (!silent) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.IllegalEnchantLevel.getValue(obj, itemStack, enchantment),
|
||||
Protections.FixIllegalEnchantmentLevels);
|
||||
|
||||
fListener.getLog().append(Msg.IllegalEnchantLevel.getValue(obj, itemStack, enchantment),
|
||||
Protections.FixIllegalEnchantmentLevels);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!silent) {
|
||||
|
||||
fListener.getLog().append2(Msg.IllegalEnchantType.getValue(obj, itemStack, enchantment));
|
||||
|
||||
}
|
||||
|
||||
replace.add(enchantment);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!enchantment.canEnchantItem(itemStack)) {
|
||||
|
||||
if (SlimefunCompat.isValid(itemStack, enchantment)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
replace.add(enchantment);
|
||||
if (!silent) {
|
||||
|
||||
fListener.getLog().append2(Msg.IllegalEnchantType.getValue(obj, itemStack, enchantment));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (Enchantment en : replace) {
|
||||
|
||||
itemStack.removeEnchantment(en);
|
||||
if (en.canEnchantItem(itemStack)) {
|
||||
|
||||
itemStack.addEnchantment(en, en.getMaxLevel());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,110 +16,171 @@ import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
public class IrritatingLegacyChecks {
|
||||
|
||||
public static boolean isIllegallyEnchanted(ItemStack itemStack) {
|
||||
|
||||
if (itemStack == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled()
|
||||
&& !itemStack.getEnchantments().isEmpty()) {
|
||||
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled() && !itemStack.getEnchantments().isEmpty()) {
|
||||
|
||||
for (Enchantment enchantment : itemStack.getEnchantments().keySet()) {
|
||||
|
||||
if (itemStack.getEnchantmentLevel(enchantment) > enchantment.getMaxLevel()) {
|
||||
|
||||
if (SlimefunCompat.isValid(itemStack, enchantment)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (IllegalStack.isEpicRename()
|
||||
&& ((enchantment == Enchantment.LURE || enchantment == Enchantment.ARROW_INFINITE)
|
||||
&& itemStack.getEnchantmentLevel(enchantment) == 4341)) {
|
||||
&& itemStack.getEnchantmentLevel(enchantment) == 4341))
|
||||
{
|
||||
|
||||
continue;
|
||||
}
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(itemStack)) {
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(
|
||||
enchantment, itemStack.getEnchantmentLevel(enchantment))) {
|
||||
continue;
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(itemStack)) {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(enchantment,
|
||||
itemStack.getEnchantmentLevel(enchantment)))
|
||||
{
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
if (!enchantment.canEnchantItem(itemStack)) {
|
||||
|
||||
if (SlimefunCompat.isValid(itemStack, enchantment)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckItem(ItemStack item, Location location) {
|
||||
|
||||
boolean cancel = false;
|
||||
|
||||
if (item.hasItemMeta() && IllegalStack.hasShulkers()) { // check for shulkers
|
||||
|
||||
final BlockStateMeta blockStateMeta = (BlockStateMeta) item.getItemMeta();
|
||||
if (blockStateMeta.getBlockState() instanceof ShulkerBox) {
|
||||
|
||||
final ShulkerBox shulker = (ShulkerBox) blockStateMeta.getBlockState();
|
||||
for (ItemStack itemStack : shulker.getInventory().getContents()) {
|
||||
|
||||
boolean overstacked = false;
|
||||
boolean illegalEnchanted = false;
|
||||
if (Protections.RemoveOverstackedItems.isEnabled()) {
|
||||
|
||||
overstacked = IrritatingLegacyChecks.CheckContainer(itemStack, location);
|
||||
|
||||
}
|
||||
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled()) {
|
||||
|
||||
illegalEnchanted = isIllegallyEnchanted(itemStack);
|
||||
|
||||
}
|
||||
|
||||
if (overstacked || illegalEnchanted) {
|
||||
|
||||
cancel = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else { // should be a single item.
|
||||
|
||||
cancel = CheckForOverstackedItems(item);
|
||||
|
||||
}
|
||||
|
||||
return cancel;
|
||||
|
||||
}
|
||||
|
||||
private static boolean CheckForOverstackedItems(ItemStack item) {
|
||||
|
||||
return item.getAmount() > item.getType().getMaxStackSize();
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckContainer(ItemStack itemStack, Location loc) {
|
||||
|
||||
if (itemStack == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (itemStack.getAmount() > itemStack.getMaxStackSize()) {
|
||||
|
||||
return !Protections.AllowStack.isWhitelisted(itemStack.getType().name(), null);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckContainer(Block block) {
|
||||
|
||||
BlockState blockState = block.getState();
|
||||
boolean invalid = false;
|
||||
|
||||
if (blockState instanceof InventoryHolder) {
|
||||
|
||||
for (ItemStack itemStack : ((InventoryHolder) blockState).getInventory()) {
|
||||
|
||||
if (itemStack != null && CheckItem(itemStack, block.getLocation())) {
|
||||
Scheduler.runTaskLater(
|
||||
IllegalStack.getPlugin(),
|
||||
() -> {
|
||||
((InventoryHolder) blockState).getInventory().removeItem(itemStack);
|
||||
},
|
||||
2,
|
||||
blockState.getLocation());
|
||||
|
||||
Scheduler.runTaskLater(IllegalStack.getPlugin(), () -> {
|
||||
|
||||
((InventoryHolder) blockState).getInventory().removeItem(itemStack);
|
||||
|
||||
}, 2, blockState.getLocation());
|
||||
invalid = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return invalid;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,87 +15,137 @@ public class OverstackedItemCheck {
|
||||
public static boolean CheckForOverstackedItems(ItemStack itemStack, Object obj) {
|
||||
|
||||
if (itemStack != null && (obj instanceof Inventory || obj instanceof Container)) {
|
||||
|
||||
return CheckContainer(itemStack, obj);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckStorageInventory(Inventory inv, Player player) {
|
||||
|
||||
if (!IllegalStack.hasStorage()) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
for (ItemStack is : inv.getStorageContents()) {
|
||||
|
||||
if (is != null && is.getType() != Material.AIR && CheckContainer(is, inv, true)) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append2(Msg.GenericItemRemoval.getValue(
|
||||
is, Protections.RemoveOverstackedItems, player, "Crafting Inventory"));
|
||||
|
||||
fListener.getLog().append2(Msg.GenericItemRemoval.getValue(is, Protections.RemoveOverstackedItems,
|
||||
player, "Crafting Inventory"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckContainer(ItemStack itemStack, Object obj) {
|
||||
|
||||
return CheckContainer(itemStack, obj, false);
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckContainer(ItemStack is, Object obj, Boolean silent) {
|
||||
|
||||
if (is == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (is.getAmount() > is.getMaxStackSize()) {
|
||||
|
||||
if (!Protections.IllegalStackMode.isEnabled()) { // in blacklist mode and on the blacklist
|
||||
|
||||
if (Protections.FixOverstackedItemInstead.isEnabled()) {
|
||||
|
||||
if (!silent) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append(Msg.IllegalStackShorten.getValue(obj, is), Protections.RemoveOverstackedItems);
|
||||
|
||||
fListener.getLog().append(Msg.IllegalStackShorten.getValue(obj, is),
|
||||
Protections.RemoveOverstackedItems);
|
||||
|
||||
}
|
||||
|
||||
is.setAmount(is.getType().getMaxStackSize());
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
if (!silent) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append(Msg.IllegalStackItemScan.getValue(obj, is), Protections.RemoveOverstackedItems);
|
||||
|
||||
fListener.getLog().append(Msg.IllegalStackItemScan.getValue(obj, is),
|
||||
Protections.RemoveOverstackedItems);
|
||||
|
||||
}
|
||||
|
||||
if (obj instanceof Inventory) {
|
||||
|
||||
((Inventory) obj).remove(is);
|
||||
|
||||
} else {
|
||||
|
||||
((Container) obj).getInventory().remove(is);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Protections.AllowStack.isWhitelisted(is.getType().name(), null)) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (Protections.FixOverstackedItemInstead.isEnabled()) {
|
||||
|
||||
if (!silent) {
|
||||
|
||||
fListener.getLog().append2(Msg.IllegalStackShorten.getValue(obj, is));
|
||||
|
||||
}
|
||||
|
||||
is.setAmount(is.getType().getMaxStackSize());
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
if (!silent) {
|
||||
|
||||
fListener.getLog().append2(Msg.IllegalStackItemScan.getValue(obj, is));
|
||||
|
||||
}
|
||||
|
||||
if (obj instanceof Inventory) {
|
||||
|
||||
((Inventory) obj).remove(is);
|
||||
|
||||
} else {
|
||||
|
||||
((Container) obj).getInventory().remove(is);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,21 +14,33 @@ public class RemoveItemTypesCheck {
|
||||
public static boolean CheckForIllegalTypes(ItemStack itemStack, Object obj) {
|
||||
|
||||
if (itemStack != null
|
||||
&& (obj instanceof Inventory || (IllegalStack.hasContainers() && obj instanceof Container))) {
|
||||
&& (obj instanceof Inventory || (IllegalStack.hasContainers() && obj instanceof Container)))
|
||||
{
|
||||
|
||||
if (shouldRemove(itemStack, obj)) {
|
||||
|
||||
if (obj instanceof Inventory) {
|
||||
|
||||
((Inventory) obj).remove(itemStack);
|
||||
|
||||
} else {
|
||||
|
||||
((Container) obj).getInventory().remove(itemStack);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean shouldRemove(Material type) {
|
||||
|
||||
return Protections.RemoveItemTypes.isWhitelisted(type);
|
||||
|
||||
}
|
||||
|
||||
public static boolean shouldRemove(ItemStack itemStack, Object obj) {
|
||||
@@ -36,18 +48,23 @@ public class RemoveItemTypesCheck {
|
||||
if (Protections.RemoveItemTypes.isWhitelisted(itemStack)) {
|
||||
|
||||
if (obj != null && Protections.RemoveItemTypes.notifyOnly()) {
|
||||
fListener
|
||||
.getLog()
|
||||
.notify(
|
||||
Protections.RemoveItemTypes,
|
||||
" Triggered by: a container with item: "
|
||||
+ itemStack.getType().name());
|
||||
|
||||
fListener.getLog().notify(Protections.RemoveItemTypes,
|
||||
" Triggered by: a container with item: " + itemStack.getType().name());
|
||||
return false;
|
||||
|
||||
} else if (obj != null) {
|
||||
|
||||
fListener.getLog().append2(Msg.ItemTypeRemoved.getValue(obj, itemStack, null));
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,21 +26,31 @@ public class IllegalStackCommand implements CommandExecutor, TabCompleter {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if (args.length == 1) {
|
||||
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "[IllegalStack] - All configuration settings have been reloaded.");
|
||||
IllegalStack.ReloadConfig(true);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (args.length >= 1) {
|
||||
|
||||
if (args[0].toLowerCase().startsWith("ver")) {
|
||||
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String ver = IllegalStack.getPlugin().getDescription().getVersion();
|
||||
@@ -48,24 +58,41 @@ public class IllegalStackCommand implements CommandExecutor, TabCompleter {
|
||||
sender.sendMessage(ChatColor.GOLD + " Detected Server Version: " + IllegalStack.getVersion()
|
||||
+ (IllegalStack.isSpigot() ? "" : "Spigot"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args[0].toLowerCase().startsWith("fix")) {
|
||||
|
||||
if (sender instanceof Player) {
|
||||
|
||||
if (sender.hasPermission("IllegalStack.fixCommand")) {
|
||||
|
||||
Protections.fixEnchants(((Player) sender));
|
||||
|
||||
} else {
|
||||
|
||||
sender.sendMessage("You don't have permission to force fix enchantment levels on an item.");
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
sender.sendMessage("This command can only be used in game by a player.");
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args[0].toLowerCase().startsWith("prot")) {
|
||||
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + "-----===== Illegal Stack Protections =====-----");
|
||||
sender.sendMessage(ChatColor.GOLD + " Detected Server Version: " + IllegalStack.getVersion()
|
||||
+ (IllegalStack.isSpigot() ? "" : "Spigot"));
|
||||
@@ -73,218 +100,355 @@ public class IllegalStackCommand implements CommandExecutor, TabCompleter {
|
||||
int parentId = 0;
|
||||
int catId = 0;
|
||||
if (args.length >= 2) {
|
||||
|
||||
try {
|
||||
|
||||
catId = Integer.parseInt(args[1].trim());
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (args.length == 3) {
|
||||
|
||||
try {
|
||||
|
||||
parentId = Integer.parseInt(args[2].trim());
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
for (Protections p : Protections.values()) {
|
||||
if (!p.getCommand().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (p.isVersionSpecific(IllegalStack.getVersion())
|
||||
&& p.isRelevantToVersion(IllegalStack.getVersion())
|
||||
&& p.getCatId() != 2) {
|
||||
sendProtection(sender, p, parentId, catId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// sender.sendMessage(ChatColor.AQUA + "- Multi-Version Protections -");
|
||||
for (Protections p : Protections.values()) {
|
||||
|
||||
if (!p.getCommand().isEmpty()) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (p.isVersionSpecific(IllegalStack.getVersion())
|
||||
&& p.isRelevantToVersion(IllegalStack.getVersion()) && p.getCatId() != 2)
|
||||
{
|
||||
|
||||
sendProtection(sender, p, parentId, catId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// sender.sendMessage(ChatColor.AQUA + "- Multi-Version Protections -");
|
||||
sendCategory(sender, "Multi-Version Protections", (catId == 1), 1);
|
||||
if (catId == 1) {
|
||||
|
||||
for (Protections p : Protections.values()) {
|
||||
|
||||
if (!p.getCommand().isEmpty() || p.getCatId() == 2) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (p.isRelevantToVersion(IllegalStack.getVersion())
|
||||
&& !p.isVersionSpecific(IllegalStack.getVersion())) {
|
||||
&& !p.isVersionSpecific(IllegalStack.getVersion()))
|
||||
{
|
||||
|
||||
sendProtection(sender, p, parentId, catId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sendCategory(sender, "Misc / User Requested Features", (catId == 2), 2);
|
||||
// sender.sendMessage(ChatColor.AQUA + "- Misc / User Requested Features -");
|
||||
// sender.sendMessage(ChatColor.AQUA + "- Misc / User Requested Features -");
|
||||
if (catId == 2) {
|
||||
|
||||
for (Protections p : Protections.values()) {
|
||||
|
||||
if (!p.getCommand().isEmpty()) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (p.isRelevantToVersion(IllegalStack.getVersion()) && p.getCatId() == catId) {
|
||||
|
||||
sendProtection(sender, p, parentId, catId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
|
||||
if (args[0].equalsIgnoreCase("enchantwhitelistmode")) {
|
||||
|
||||
if (sender instanceof Player) {
|
||||
|
||||
Player plr = (Player) sender;
|
||||
if (!fListener.getInstance().getItemWatcher().remove(plr)) {
|
||||
|
||||
fListener.getInstance().getItemWatcher().add(plr);
|
||||
plr.sendMessage(Msg.StaffEnchantBypass.getValue());
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
plr.sendMessage(Msg.StaffEnchantBypassCancel.getValue());
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
|
||||
if (args[0].equalsIgnoreCase("teleport")) {
|
||||
|
||||
if (!hasPerm(sender, "illegalstack.notify")) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
|
||||
if (args.length >= 4) {
|
||||
|
||||
World w = IllegalStack.getPlugin().getServer().getWorld(args[4]);
|
||||
Location loc = new Location(
|
||||
w, Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]));
|
||||
Location loc = new Location(w, Integer.parseInt(args[1]), Integer.parseInt(args[2]),
|
||||
Integer.parseInt(args[3]));
|
||||
if (Scheduler.FOLIA) {
|
||||
|
||||
((Player) sender).teleportAsync(loc);
|
||||
|
||||
} else {
|
||||
|
||||
((Player) sender).teleport(loc);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
sender.sendMessage("This command can only be used by players.");
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
Protections p = Protections.getProtection(args[1]);
|
||||
if (p != null) {
|
||||
|
||||
p.toggleProtection();
|
||||
String status = "ON";
|
||||
if (!p.isEnabled()) {
|
||||
|
||||
status = "OFF";
|
||||
|
||||
}
|
||||
|
||||
fListener.getLog().append2(Msg.StaffProtectionToggleMsg.getValue(p, sender.getName(), status));
|
||||
refreshCommands(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (args.length >= 4) {
|
||||
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("value")) {
|
||||
|
||||
Protections pro = Protections.getProtection(args[2]);
|
||||
if (pro == null) {
|
||||
|
||||
sender.sendMessage(Msg.StaffInvalidProtectionMsg.getValue());
|
||||
StringBuilder prots = new StringBuilder();
|
||||
for (Protections p : Protections.values()) {
|
||||
|
||||
if (p.isList()) {
|
||||
|
||||
prots.append(p.name()).append(", ");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GRAY + prots.toString());
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("remove")) {
|
||||
|
||||
StringBuilder val = new StringBuilder(args[3].trim());
|
||||
if (args.length >= 4) {
|
||||
|
||||
val = new StringBuilder();
|
||||
for (int i = 3; i < args.length; i++) {
|
||||
|
||||
val.append(args[i]).append(" ");
|
||||
|
||||
}
|
||||
|
||||
val = new StringBuilder(val.toString().trim());
|
||||
|
||||
}
|
||||
|
||||
pro.remTxtSet(val.toString(), sender);
|
||||
// refreshCommands(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("add")) {
|
||||
|
||||
if (pro.validate(args[3].trim(), sender)) {
|
||||
|
||||
sender.sendMessage(Msg.StaffOptionUpdated.getValue());
|
||||
|
||||
// refreshCommands(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (args.length > 0) {
|
||||
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + "-----===== Available Protection Toggles =====-----");
|
||||
StringBuilder prots = new StringBuilder();
|
||||
for (Protections p : Protections.values()) {
|
||||
|
||||
if (p.getParentId() == 0) {
|
||||
|
||||
prots.append(p.name()).append(", ");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GRAY + prots.toString());
|
||||
sender.sendMessage(ChatColor.GOLD + "/istack toggle <protection>" + ChatColor.GRAY
|
||||
+ " - Toggles a protection on/off");
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("value")) {
|
||||
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args.length > 3 && args[1].equalsIgnoreCase("add")) {
|
||||
|
||||
Protections pro = Protections.getProtection(args[2]);
|
||||
if (pro != Protections.ItemNamesToRemove && pro != Protections.ItemLoresToRemove) {
|
||||
|
||||
sender.sendMessage(Msg.StaffSingleWordsOnly.getValue());
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (int i = 3; i < args.length; i++) {
|
||||
|
||||
text.append(args[i]).append(" ");
|
||||
|
||||
}
|
||||
|
||||
if (pro.validate(text.toString().trim(), sender)) {
|
||||
|
||||
sender.sendMessage(Msg.StaffStringUpdated.getValue(text.toString()));
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args.length > 3 && args[1].equalsIgnoreCase("set")) {
|
||||
|
||||
Protections pro = Protections.getProtection(args[2]);
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (int i = 3; i < args.length; i++) {
|
||||
|
||||
text.append(args[i]).append(" ");
|
||||
|
||||
}
|
||||
|
||||
if (pro.validate(text.toString(), sender)) {
|
||||
|
||||
sender.sendMessage(Msg.StaffOptionUpdated.getValue());
|
||||
|
||||
// refreshCommands(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + "-----===== Available Protection Options =====-----");
|
||||
sender.sendMessage(ChatColor.GOLD + "/istack values < set | remove > <protection>" + ChatColor.GRAY
|
||||
+ " - Add/Remove a value from a protection's list");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + "Illegal Stack - Available Commands");
|
||||
@@ -294,26 +458,38 @@ public class IllegalStackCommand implements CommandExecutor, TabCompleter {
|
||||
sender.sendMessage(ChatColor.GOLD + "/istack reload" + ChatColor.GRAY + " - Reloads config from config.yml");
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private boolean hasPerm(CommandSender sender, String perm) {
|
||||
|
||||
if (sender.hasPermission(perm)) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(Msg.StaffMsgNoPerm.getValue(perm));
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private void sendCategory(CommandSender sender, String category, Boolean show, int catId) {
|
||||
|
||||
Player plr = null;
|
||||
if (sender instanceof Player) {
|
||||
|
||||
plr = (Player) sender;
|
||||
|
||||
}
|
||||
|
||||
if (IllegalStack.isSpigot() && plr != null) {
|
||||
|
||||
plr.spigot().sendMessage(SpigotMethods.makeCategoryText(category, show, catId));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void sendProtection(CommandSender sender, Protections p, int parentId, int catId) {
|
||||
@@ -322,62 +498,90 @@ public class IllegalStackCommand implements CommandExecutor, TabCompleter {
|
||||
String status = ChatColor.GREEN + " ON";
|
||||
Player plr = null;
|
||||
if (sender instanceof Player) {
|
||||
|
||||
plr = (Player) sender;
|
||||
|
||||
}
|
||||
|
||||
if (!p.isEnabled()) {
|
||||
|
||||
status = ChatColor.DARK_RED + "OFF";
|
||||
|
||||
}
|
||||
|
||||
if (IllegalStack.isSpigot() && plr != null) {
|
||||
|
||||
boolean hasKids = false;
|
||||
HashSet<Protections> kids = new HashSet<>();
|
||||
for (Protections child : Protections.values()) {
|
||||
|
||||
if (child.getParentId() == p.getProtId()) {
|
||||
|
||||
hasKids = true;
|
||||
kids.add(child);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
plr.spigot().sendMessage(SpigotMethods.makeParentText(p, status, hasKids, catId));
|
||||
for (Protections child : kids) {
|
||||
|
||||
if (parentId != 0 && parentId == p.getProtId()) {
|
||||
|
||||
plr.spigot().sendMessage(SpigotMethods.makeChildText(child, catId));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!p.isList()) {
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "[" + status + ChatColor.GOLD + "] " + ChatColor.DARK_AQUA + ""
|
||||
+ p.getDisplayName() + "");
|
||||
|
||||
} else {
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "[" + " " + ChatColor.DARK_GRAY + "] " + ChatColor.DARK_AQUA
|
||||
+ "" + p.getDisplayName() + " " + p.findValue());
|
||||
|
||||
}
|
||||
|
||||
for (Protections child : Protections.values()) {
|
||||
|
||||
if (child.getParentId() == p.getProtId()) {
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + "-> " + ChatColor.DARK_AQUA + child.getDisplayName() + " "
|
||||
+ ChatColor.GRAY + child.findValue());
|
||||
line = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (line) {
|
||||
|
||||
sender.sendMessage(" ");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void refreshCommands(final CommandSender sender) {
|
||||
Scheduler.runTaskLater(
|
||||
IllegalStack.getPlugin(),
|
||||
() -> IllegalStack.getPlugin().getServer().dispatchCommand(sender, "istack prot"),
|
||||
5);
|
||||
|
||||
Scheduler.runTaskLater(IllegalStack.getPlugin(),
|
||||
() -> IllegalStack.getPlugin().getServer().dispatchCommand(sender, "istack prot"), 5);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull final CommandSender sender,
|
||||
@NotNull final Command command,
|
||||
@NotNull final String label,
|
||||
final @NotNull String[] args) {
|
||||
public @Nullable List<String> onTabComplete(@NotNull final CommandSender sender, @NotNull final Command command,
|
||||
@NotNull final String label, final @NotNull String[] args)
|
||||
{
|
||||
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.add("protections");
|
||||
@@ -386,13 +590,23 @@ public class IllegalStackCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
|
||||
for (String a : arguments) {
|
||||
|
||||
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
|
||||
result.add(a);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,16 +18,15 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public enum Msg {
|
||||
|
||||
// @ Location of offense
|
||||
// @ Location of offense
|
||||
// ~name~ name of player or entity
|
||||
// ~contents~ contents of an item frame
|
||||
// ~removedblocks~ blocked removed
|
||||
// ~author~ book author
|
||||
// ~blockType block type
|
||||
// ~author~ book author
|
||||
// ~blockType block type
|
||||
// ~item~
|
||||
|
||||
PluginPrefix("[IllegalStack] -"),
|
||||
PluginTeleportText(ChatColor.GOLD + "Click to teleport here"),
|
||||
PluginPrefix("[IllegalStack] -"), PluginTeleportText(ChatColor.GOLD + "Click to teleport here"),
|
||||
|
||||
ChestRemoved("removed a chest from a ~entity~ @"),
|
||||
ChestPrevented("prevented ~player~ from putting a chest on a ~entity~ @"),
|
||||
@@ -145,8 +144,7 @@ public enum Msg {
|
||||
StaffBadShulkerInWorld(
|
||||
"Removed a dropped shulker box with an excessive amount of items in it (~size~) from the world: @"),
|
||||
StaffNoItem("You must be holding an item in your main hand to force fix it's enchantment!"),
|
||||
StaffNoEnchants("This item has no enchants to fix!"),
|
||||
StaffEnchantFixed("Corrected ~amount~ enchants on ~item~"),
|
||||
StaffNoEnchants("This item has no enchants to fix!"), StaffEnchantFixed("Corrected ~amount~ enchants on ~item~"),
|
||||
StaffNoNBTAPI(
|
||||
"NBT-Api was not found on your server and is needed for ~prot~ since it is enabled! Please download and install it from: https://www.spigotmc.org/resources/nbt-api.7939/"),
|
||||
StaffEnchantNotFixed("IllegalStack did not detect any invalid enchantments on this item."),
|
||||
@@ -165,10 +163,13 @@ public enum Msg {
|
||||
private String value;
|
||||
|
||||
Msg(String val) {
|
||||
|
||||
this.setValue(val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(String variable) {
|
||||
|
||||
String val = value;
|
||||
val = val.replace("~perm~", variable);
|
||||
val = val.replace("~prot~", variable);
|
||||
@@ -179,9 +180,11 @@ public enum Msg {
|
||||
val = val.replace("@", "@" + variable);
|
||||
val = val.replace("~value~", variable);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Location location, String types) {
|
||||
|
||||
String val = value;
|
||||
val = val.replace("@", "@ " + location.toString());
|
||||
val = val.replace("~removedblocks~", types);
|
||||
@@ -189,22 +192,28 @@ public enum Msg {
|
||||
val = val.replace("~item~", types);
|
||||
val = val.replace("~name~", types);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(ItemStack is, Protections prot, Player plr, String source) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~protection~", prot.getDisplayName());
|
||||
val = val.replace("~source~", source);
|
||||
if (plr != null) {
|
||||
|
||||
val = plr.getName() + " - " + val;
|
||||
|
||||
}
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player player, String displayName) {
|
||||
|
||||
String val = value;
|
||||
val = val.replace("@", "@ " + player.getLocation());
|
||||
val = val.replace("~item~", displayName);
|
||||
@@ -214,42 +223,52 @@ public enum Msg {
|
||||
val = val.replace("~block~", displayName);
|
||||
val = val.replace("~effects~", displayName);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(HumanEntity le, String value) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~author~", value);
|
||||
val = val.replace("~name~", le.getName());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, Location loc) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(String source, Location loc) {
|
||||
|
||||
String val = value;
|
||||
val = val.replace("~type~", source);
|
||||
val = val.replace("~player~", source);
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, Integer count, Location loc) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
val = val.replace("~count~", count.toString());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, Entity ent) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~name~", p.getName());
|
||||
@@ -258,29 +277,38 @@ public enum Msg {
|
||||
val = val.replace("~vehicle~", ent.getType().name());
|
||||
val = val.replace("@", "@ " + ent.getLocation());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Entity ent1, Entity ent2) {
|
||||
|
||||
String val = value;
|
||||
|
||||
if (ent1 instanceof Player) {
|
||||
|
||||
val = val.replace("~entity~", ent1.getName());
|
||||
|
||||
} else {
|
||||
|
||||
val = val.replace("~entity~", ent1.getType().name());
|
||||
|
||||
}
|
||||
|
||||
val = val.replace("~vehicle~", ent2.getType().name());
|
||||
val = val.replace("@", "@ " + ent1.getLocation());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Location loc, ItemStack is) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Object obj, ItemStack is, Enchantment en) {
|
||||
@@ -289,50 +317,84 @@ public enum Msg {
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
if (en == null) {
|
||||
|
||||
val = val.replace("~enchant~", "");
|
||||
|
||||
} else {
|
||||
|
||||
val = val.replace("~enchant~", en.getName());
|
||||
val = val.replace("~lvl~", is.getEnchantmentLevel(en) + "");
|
||||
|
||||
}
|
||||
|
||||
if (obj instanceof BlockState) {
|
||||
val = val.replace(
|
||||
"~player~", "a " + ((BlockState) obj).getBlock().getType().name() + "'s inventory");
|
||||
|
||||
val = val.replace("~player~", "a " + ((BlockState) obj).getBlock().getType().name() + "'s inventory");
|
||||
|
||||
} else if (obj instanceof Player) {
|
||||
|
||||
val = val.replace("~player~", ((Player) obj).getName());
|
||||
|
||||
} else if (obj instanceof Inventory) {
|
||||
|
||||
val = val.replace("~player~", ((Inventory) obj).getType().name() + " - ");
|
||||
|
||||
} else if (obj instanceof Location) {
|
||||
|
||||
val = val.replace("~player~", "a shulker box");
|
||||
|
||||
} else if (obj instanceof Container) {
|
||||
|
||||
val = val.replace("~player~", ((Container) obj).getType().name());
|
||||
|
||||
}
|
||||
|
||||
Location loc = null;
|
||||
|
||||
if (obj instanceof BlockState) {
|
||||
|
||||
loc = ((BlockState) obj).getLocation();
|
||||
|
||||
}
|
||||
|
||||
if (obj instanceof Player) {
|
||||
|
||||
loc = ((Player) obj).getLocation();
|
||||
|
||||
} else if (obj instanceof Block) {
|
||||
|
||||
loc = ((Block) obj).getLocation();
|
||||
|
||||
} else if (obj instanceof Inventory) {
|
||||
|
||||
loc = ((Inventory) obj).getLocation();
|
||||
|
||||
} else if (obj instanceof Location) {
|
||||
|
||||
loc = ((Location) obj);
|
||||
|
||||
} else if (obj instanceof Container) {
|
||||
|
||||
loc = ((Container) obj).getLocation();
|
||||
|
||||
}
|
||||
|
||||
if (loc != null) {
|
||||
|
||||
val = val.replace("@", "@ " + loc);
|
||||
|
||||
} else {
|
||||
|
||||
val = val.replace("@", "@ UNKNOWN ");
|
||||
|
||||
}
|
||||
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is, Enchantment en) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
@@ -341,35 +403,50 @@ public enum Msg {
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, EntityType et) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
val = val.replace("~type~", et.name());
|
||||
val = val.replace("~name~", p.getName());
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Object obj, ItemStack is) {
|
||||
|
||||
if (obj instanceof Inventory) {
|
||||
|
||||
if (((Inventory) obj).getHolder() instanceof Player) {
|
||||
|
||||
Inventory inv = (Inventory) obj;
|
||||
return getValue((Player) inv.getHolder(), is);
|
||||
|
||||
} else {
|
||||
|
||||
return getValue(((Inventory) obj).getLocation(), is);
|
||||
|
||||
}
|
||||
|
||||
} else if (obj instanceof Container) {
|
||||
|
||||
return getValue(((Container) obj), is);
|
||||
|
||||
}
|
||||
|
||||
LOGGER.error(
|
||||
"An unknown object {} was passed to IllegalStack during a logging operation please report this to dNiym at the spigot forums or on the IllegalStack Discord.",
|
||||
obj.toString());
|
||||
return "???";
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Container c, ItemStack is) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + c.getLocation());
|
||||
@@ -377,9 +454,11 @@ public enum Msg {
|
||||
val = val.replace("~name~", c.getType().name());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
@@ -388,43 +467,44 @@ public enum Msg {
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(ItemStack is, Object obj, StringBuilder list) {
|
||||
|
||||
String val = value;
|
||||
|
||||
if (obj instanceof Player) {
|
||||
|
||||
val = val.replace("@", "@ " + ((Player) obj).getLocation());
|
||||
val = val.replace("~name~", ((Player) obj).getName());
|
||||
|
||||
} else if (obj instanceof Inventory) {
|
||||
|
||||
Inventory inv = null;
|
||||
inv = (Inventory) obj;
|
||||
if (inv.getHolder() instanceof Container) {
|
||||
val = val.replace(
|
||||
"~name~",
|
||||
((Container) inv.getHolder())
|
||||
.getLocation()
|
||||
.getBlock()
|
||||
.getType()
|
||||
.name() + " @" + ((Container) inv.getHolder()).getLocation());
|
||||
|
||||
val = val.replace("~name~", ((Container) inv.getHolder()).getLocation().getBlock().getType().name()
|
||||
+ " @" + ((Container) inv.getHolder()).getLocation());
|
||||
|
||||
} else if (inv.getHolder() instanceof DoubleChest) {
|
||||
val = val.replace(
|
||||
"~name~",
|
||||
((DoubleChest) inv.getHolder())
|
||||
.getLocation()
|
||||
.getBlock()
|
||||
.getType()
|
||||
.name() + " @" + inv.getLocation().toString());
|
||||
|
||||
val = val.replace("~name~", ((DoubleChest) inv.getHolder()).getLocation().getBlock().getType().name()
|
||||
+ " @" + inv.getLocation().toString());
|
||||
|
||||
} else if (inv.getHolder() instanceof Player) {
|
||||
val = val.replace(
|
||||
"~name~",
|
||||
((Player) inv.getHolder()).getName() + " @"
|
||||
+ inv.getLocation().toString());
|
||||
|
||||
val = val.replace("~name~", ((Player) inv.getHolder()).getName() + " @" + inv.getLocation().toString());
|
||||
|
||||
} else {
|
||||
|
||||
LOGGER.error(
|
||||
"IllegalStack was supposed to send a message detailing an inventory but could not determine its type! Please contact dNiym at the IllegalStack discord or on Spigot with this message: {} ",
|
||||
obj.toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
@@ -432,9 +512,11 @@ public enum Msg {
|
||||
val = val.replace("~attributes~", list);
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is, String list) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
@@ -443,30 +525,40 @@ public enum Msg {
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
val = val.replace("~attributes~", list);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getConfigVal() {
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', value);
|
||||
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
|
||||
this.value = value;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Protections p, String name, String status) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~protection~", p.name());
|
||||
val = val.replace("~name~", name);
|
||||
val = val.replace("~status~", "" + status);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, int size) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
@@ -474,17 +566,21 @@ public enum Msg {
|
||||
val = val.replace("~name~", p.getName());
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Location loc, int size) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
val = val.replace("~size~", "" + size);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is, int lostItems) {
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
@@ -493,5 +589,7 @@ public enum Msg {
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
val = val.replace("~lost~", "" + lostItems);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,59 +1,51 @@
|
||||
package main.java.me.dniym.enums;
|
||||
|
||||
public enum ServerVersion {
|
||||
v1_8_R1,
|
||||
v1_8_R2,
|
||||
v1_8_R3,
|
||||
v1_9_R1,
|
||||
v1_9_R2,
|
||||
v1_10_R1,
|
||||
v1_11_R1,
|
||||
v1_12_R1,
|
||||
v1_13_R1,
|
||||
v1_13_R2,
|
||||
v1_14_R1,
|
||||
v1_15_R1,
|
||||
v1_16_R1,
|
||||
v1_16_R2,
|
||||
v1_16_R3,
|
||||
v1_17_R1,
|
||||
v1_18_R1,
|
||||
v1_18_R2,
|
||||
v1_19_R1,
|
||||
v1_19_R2,
|
||||
v1_19_R3,
|
||||
v1_20_R1,
|
||||
v1_20_R2,
|
||||
v1_20_R3,
|
||||
v1_20_R4,
|
||||
v1_20_R5,
|
||||
v1_21_R1;
|
||||
|
||||
v1_8_R1, v1_8_R2, v1_8_R3, v1_9_R1, v1_9_R2, v1_10_R1, v1_11_R1, v1_12_R1, v1_13_R1, v1_13_R2, v1_14_R1, v1_15_R1,
|
||||
v1_16_R1, v1_16_R2, v1_16_R3, v1_17_R1, v1_18_R1, v1_18_R2, v1_19_R1, v1_19_R2, v1_19_R3, v1_20_R1, v1_20_R2,
|
||||
v1_20_R3, v1_20_R4, v1_20_R5, v1_21_R1;
|
||||
|
||||
public boolean serverVersionEqual(ServerVersion version) {
|
||||
|
||||
return this.equals(version);
|
||||
|
||||
}
|
||||
|
||||
public boolean serverVersionGreaterThanOrEqual(ServerVersion version) {
|
||||
|
||||
return this.ordinal() >= version.ordinal();
|
||||
|
||||
}
|
||||
|
||||
public boolean serverVersionGreaterThan(ServerVersion version1, ServerVersion version2) {
|
||||
|
||||
return version1.ordinal() > version2.ordinal();
|
||||
|
||||
}
|
||||
|
||||
public boolean serverVersionLessThan(ServerVersion version1, ServerVersion version2) {
|
||||
|
||||
return version1.ordinal() < version2.ordinal();
|
||||
|
||||
}
|
||||
|
||||
public String getServerVersionName() {
|
||||
|
||||
return this.name();
|
||||
|
||||
}
|
||||
|
||||
public int getOrdinalServerVersionNumber() {
|
||||
|
||||
return this.ordinal();
|
||||
|
||||
}
|
||||
|
||||
public int getServerMajorVersionNumber() {
|
||||
|
||||
return Integer.parseInt(this.name().split("_")[1]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,85 +20,116 @@ public class IllegalStackActionEvent extends Event implements Cancellable {
|
||||
private Entity mount;
|
||||
private Inventory affectedInventory;
|
||||
|
||||
public IllegalStackActionEvent(
|
||||
Protections protections,
|
||||
Entity entity,
|
||||
Block block,
|
||||
ItemStack itemStack,
|
||||
Entity entity1,
|
||||
Inventory inventory) {
|
||||
public IllegalStackActionEvent(Protections protections, Entity entity, Block block, ItemStack itemStack,
|
||||
Entity entity1, Inventory inventory)
|
||||
{
|
||||
|
||||
this.protection = protections;
|
||||
this.setCause(entity);
|
||||
this.block = block;
|
||||
this.item = itemStack;
|
||||
this.setMount(entity1);
|
||||
this.affectedInventory = inventory;
|
||||
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
return cancelled;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
|
||||
cancelled = cancel;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
public Protections getProtection() {
|
||||
|
||||
return protection;
|
||||
|
||||
}
|
||||
|
||||
public void setProtection(Protections protection) {
|
||||
|
||||
this.protection = protection;
|
||||
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
|
||||
return block;
|
||||
|
||||
}
|
||||
|
||||
public void setBlock(Block block) {
|
||||
|
||||
this.block = block;
|
||||
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
public void setItem(ItemStack item) {
|
||||
|
||||
this.item = item;
|
||||
|
||||
}
|
||||
|
||||
public Entity getMount() {
|
||||
|
||||
return mount;
|
||||
|
||||
}
|
||||
|
||||
public void setMount(Entity mount) {
|
||||
|
||||
this.mount = mount;
|
||||
|
||||
}
|
||||
|
||||
public Entity getCause() {
|
||||
|
||||
return cause;
|
||||
|
||||
}
|
||||
|
||||
public void setCause(Entity cause) {
|
||||
|
||||
this.cause = cause;
|
||||
|
||||
}
|
||||
|
||||
public Inventory getAffectedInventory() {
|
||||
|
||||
return affectedInventory;
|
||||
|
||||
}
|
||||
|
||||
public void setAffectedInventory(Inventory affectedInventory) {
|
||||
|
||||
this.affectedInventory = affectedInventory;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,42 +13,61 @@ public class IllegalStackLogEvent extends Event implements Cancellable {
|
||||
private Protections protection = null;
|
||||
|
||||
public IllegalStackLogEvent(String message, Protections prot) {
|
||||
|
||||
this.setMessage(message);
|
||||
this.setProtection(prot);
|
||||
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
return cancelled;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
|
||||
cancelled = cancel;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
|
||||
return message;
|
||||
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
|
||||
this.message = message;
|
||||
|
||||
}
|
||||
|
||||
public Protections getProtection() {
|
||||
|
||||
return protection;
|
||||
|
||||
}
|
||||
|
||||
public void setProtection(Protections protection) {
|
||||
|
||||
this.protection = protection;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,95 +21,154 @@ public class FishAttempt {
|
||||
private final List<Location> BLACKLIST = new ArrayList<>();
|
||||
|
||||
public FishAttempt(Player p) {
|
||||
|
||||
attempts.put(p.getUniqueId(), this);
|
||||
|
||||
}
|
||||
|
||||
public static FishAttempt findPlayer(Player p) {
|
||||
|
||||
if (attempts.containsKey(p.getUniqueId())) {
|
||||
|
||||
return attempts.get(p.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
return new FishAttempt(p);
|
||||
|
||||
}
|
||||
|
||||
public static FishHook findHook(Player player) {
|
||||
|
||||
for (FishHook fh : player.getWorld().getEntitiesByClass(FishHook.class)) {
|
||||
|
||||
if (fh.getShooter() instanceof Player) {
|
||||
|
||||
if (fh.getShooter() == player) {
|
||||
|
||||
return fh;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public void fishCaught(Location hookLoc) {
|
||||
|
||||
if (lastLocation == null || lastLocation.getWorld() != hookLoc.getWorld()) {
|
||||
|
||||
lastLocation = hookLoc;
|
||||
|
||||
}
|
||||
|
||||
Location testLoc = hookLoc.clone();
|
||||
testLoc.setY(lastLocation.getY());
|
||||
|
||||
if (lastLocation.getWorld() == testLoc.getWorld() && lastLocation.distance(testLoc) <= range) {
|
||||
|
||||
setSameSpotCount(getSameSpotCount() + 1);
|
||||
|
||||
} else {
|
||||
|
||||
setSameSpotCount(1);
|
||||
lastLocation = hookLoc;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addAttempt() {
|
||||
|
||||
if (System.currentTimeMillis() >= lastFish) {
|
||||
|
||||
count = 1;
|
||||
|
||||
} else {
|
||||
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
lastFish = System.currentTimeMillis() + spamThreshold;
|
||||
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
|
||||
this.count = count;
|
||||
|
||||
}
|
||||
|
||||
public int getSameSpotCount() {
|
||||
|
||||
return sameSpotCount;
|
||||
|
||||
}
|
||||
|
||||
public void setSameSpotCount(int sameSpotCount) {
|
||||
|
||||
this.sameSpotCount = sameSpotCount;
|
||||
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
|
||||
sameSpotCount = 0;
|
||||
lastLocation = null;
|
||||
|
||||
}
|
||||
|
||||
public void blackList(Location location) {
|
||||
|
||||
if (getBLACKLIST().size() > 3) {
|
||||
|
||||
getBLACKLIST().remove(0);
|
||||
|
||||
}
|
||||
|
||||
getBLACKLIST().add(location);
|
||||
|
||||
}
|
||||
|
||||
public List<Location> getBLACKLIST() {
|
||||
|
||||
return BLACKLIST;
|
||||
|
||||
}
|
||||
|
||||
public boolean isBlackListedSpot(Location location) {
|
||||
|
||||
for (Location l : BLACKLIST) {
|
||||
|
||||
Location testLoc = l.clone();
|
||||
testLoc.setY(location.getY());
|
||||
if (location.getWorld() != testLoc.getWorld()) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (testLoc.distance(location) <= range) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,9 +23,11 @@ public class Listener113 implements Listener {
|
||||
IllegalStack plugin;
|
||||
|
||||
public Listener113(IllegalStack illegalStack) {
|
||||
|
||||
plugin = illegalStack;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
LOGGER.info("Enabling 1.13+ Checks");
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -36,49 +38,58 @@ public class Listener113 implements Listener {
|
||||
CreatureSpawner cs = e.getSpawner();
|
||||
EntityType et = e.getEntityType();
|
||||
if (et != null && Protections.ResetSpawnersOfTypeOnSpawn.isWhitelisted(et)) {
|
||||
|
||||
e.setCancelled(true);
|
||||
EntityType oldType = cs.getSpawnedType();
|
||||
cs.setSpawnedType(EntityType.PIG);
|
||||
cs.setBlockData(cs.getBlockData());
|
||||
cs.update(true);
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.StaffMsgSpawnerOnSpawnReset.getValue(oldType.name(), e.getLocation()),
|
||||
Protections.ResetSpawnersOfTypeOnSpawn);
|
||||
fListener.getLog().append(Msg.StaffMsgSpawnerOnSpawnReset.getValue(oldType.name(), e.getLocation()),
|
||||
Protections.ResetSpawnersOfTypeOnSpawn);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void spawnerChangeCheck(PlayerInteractEvent event) {
|
||||
|
||||
if (Protections.PreventSpawnEggsOnSpawners.isEnabled(event.getPlayer())) {
|
||||
|
||||
Player plr = event.getPlayer();
|
||||
ItemStack is = plr.getInventory().getItemInMainHand();
|
||||
|
||||
if (is == null) {
|
||||
|
||||
is = plr.getInventory().getItemInOffHand();
|
||||
|
||||
}
|
||||
|
||||
if (is != null && is.getType().name().toLowerCase().contains("spawn_egg")) {
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
|
||||
Block blk = event.getClickedBlock();
|
||||
if (blk.getType() == Material.SPAWNER && !event.getPlayer().isOp()) {
|
||||
|
||||
plr.sendMessage(Msg.PlayerSpawnEggBlock.getValue());
|
||||
event.setCancelled(true);
|
||||
|
||||
} else if (blk.getType() == Material.SPAWNER) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.StaffMsgChangedSpawnerType.getValue(
|
||||
plr, is.getType().name()),
|
||||
Protections.PreventSpawnEggsOnSpawners);
|
||||
|
||||
fListener.getLog().append(Msg.StaffMsgChangedSpawnerType.getValue(plr, is.getType().name()),
|
||||
Protections.PreventSpawnEggsOnSpawners);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,339 +49,437 @@ import org.bukkit.inventory.MerchantInventory;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
|
||||
public class Listener114 implements Listener {
|
||||
|
||||
final Logger LOGGER = LogManager.getLogger("IllegalStack/" + Listener114.class.getSimpleName());
|
||||
private static final BlockFace[] faces = {BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH};
|
||||
private static final BlockFace[] faces = { BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH };
|
||||
HashMap<UUID, Long> lastTrade = new HashMap<>();
|
||||
HashSet<Material> consumables = new HashSet<>();
|
||||
IllegalStack plugin;
|
||||
|
||||
public Listener114(IllegalStack illegalStack) {
|
||||
|
||||
plugin = illegalStack;
|
||||
|
||||
Material[] consume = new Material[] {
|
||||
Material.APPLE,
|
||||
Material.BAKED_POTATO,
|
||||
Material.BEETROOT,
|
||||
Material.BEETROOT_SOUP,
|
||||
Material.BREAD,
|
||||
Material.CARROT,
|
||||
Material.CHORUS_FRUIT,
|
||||
Material.COOKED_CHICKEN,
|
||||
Material.COOKED_COD,
|
||||
Material.COOKED_MUTTON,
|
||||
Material.COOKED_PORKCHOP,
|
||||
Material.COOKED_SALMON,
|
||||
Material.COOKED_RABBIT,
|
||||
Material.COOKIE,
|
||||
Material.DRIED_KELP,
|
||||
Material.GOLDEN_APPLE,
|
||||
Material.ENCHANTED_GOLDEN_APPLE,
|
||||
Material.GOLDEN_CARROT,
|
||||
Material.MELON_SLICE,
|
||||
Material.MUSHROOM_STEW,
|
||||
Material.POISONOUS_POTATO,
|
||||
Material.POTATO,
|
||||
Material.PUFFERFISH,
|
||||
Material.PUMPKIN_PIE,
|
||||
Material.RABBIT_STEW,
|
||||
Material.BEEF,
|
||||
Material.CHICKEN,
|
||||
Material.COD,
|
||||
Material.MUTTON,
|
||||
Material.PORKCHOP,
|
||||
Material.RABBIT,
|
||||
Material.SALMON,
|
||||
Material.ROTTEN_FLESH,
|
||||
Material.SPIDER_EYE,
|
||||
Material.COOKED_BEEF,
|
||||
Material.SUSPICIOUS_STEW,
|
||||
Material.SWEET_BERRIES,
|
||||
Material.TROPICAL_FISH,
|
||||
Material.MILK_BUCKET,
|
||||
Material.POTION
|
||||
};
|
||||
Material[] consume = new Material[] { Material.APPLE, Material.BAKED_POTATO, Material.BEETROOT,
|
||||
Material.BEETROOT_SOUP, Material.BREAD, Material.CARROT, Material.CHORUS_FRUIT, Material.COOKED_CHICKEN,
|
||||
Material.COOKED_COD, Material.COOKED_MUTTON, Material.COOKED_PORKCHOP, Material.COOKED_SALMON,
|
||||
Material.COOKED_RABBIT, Material.COOKIE, Material.DRIED_KELP, Material.GOLDEN_APPLE,
|
||||
Material.ENCHANTED_GOLDEN_APPLE, Material.GOLDEN_CARROT, Material.MELON_SLICE, Material.MUSHROOM_STEW,
|
||||
Material.POISONOUS_POTATO, Material.POTATO, Material.PUFFERFISH, Material.PUMPKIN_PIE,
|
||||
Material.RABBIT_STEW, Material.BEEF, Material.CHICKEN, Material.COD, Material.MUTTON, Material.PORKCHOP,
|
||||
Material.RABBIT, Material.SALMON, Material.ROTTEN_FLESH, Material.SPIDER_EYE, Material.COOKED_BEEF,
|
||||
Material.SUSPICIOUS_STEW, Material.SWEET_BERRIES, Material.TROPICAL_FISH, Material.MILK_BUCKET,
|
||||
Material.POTION };
|
||||
consumables.addAll(Arrays.asList(consume));
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChestDispense(BlockDispenseArmorEvent e) {
|
||||
|
||||
if (Protections.DisableChestsOnMobs.isEnabled(e.getBlock().getLocation())) {
|
||||
|
||||
if (e.getItem().getType() == Material.CHEST) {
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnVillagerTransform(EntityTransformEvent e) {
|
||||
|
||||
if (Protections.ZombieVillagerTransformChance.getIntValue() < 100
|
||||
&& !Protections.ZombieVillagerTransformChance.isDisabledInWorld(
|
||||
e.getEntity().getWorld())) {
|
||||
&& !Protections.ZombieVillagerTransformChance.isDisabledInWorld(e.getEntity().getWorld()))
|
||||
{
|
||||
|
||||
for (Entity ent : e.getTransformedEntities()) {
|
||||
|
||||
if (ent instanceof ZombieVillager) {
|
||||
|
||||
if (Protections.ZombieVillagerTransformChance.getIntValue() <= 0) {
|
||||
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
int roll = ThreadLocalRandom.current().nextInt(1, 100);
|
||||
|
||||
if (roll > Protections.ZombieVillagerTransformChance.getIntValue()) {
|
||||
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnVillagerInteract(PlayerInteractEntityEvent e) {
|
||||
|
||||
if (Protections.PreventVillagerSwimExploit.isEnabled(e.getPlayer())) {
|
||||
if (e.getRightClicked() != null
|
||||
&& e.getRightClicked() instanceof Villager
|
||||
&& e.getRightClicked() instanceof Merchant) {
|
||||
|
||||
if (e.getRightClicked() != null && e.getRightClicked() instanceof Villager
|
||||
&& e.getRightClicked() instanceof Merchant)
|
||||
{
|
||||
|
||||
boolean cancel = false;
|
||||
|
||||
Villager v = (Villager) e.getRightClicked();
|
||||
|
||||
if (v.getLocation().getBlock().getType() == Material.WATER) {
|
||||
|
||||
cancel = true;
|
||||
|
||||
}
|
||||
|
||||
Block down = v.getLocation().getBlock();
|
||||
if (down.getBlockData() instanceof Waterlogged) {
|
||||
|
||||
Waterlogged wl = (Waterlogged) down.getBlockData();
|
||||
if (wl.isWaterlogged()) {
|
||||
|
||||
cancel = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (cancel) {
|
||||
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().sendMessage(Msg.PlayerSwimExploitMsg.getValue());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
|
||||
if (Protections.SilkTouchBookExploit.isEnabled(e.getPlayer())) {
|
||||
|
||||
Player p = e.getPlayer();
|
||||
if (p != null && p.getInventory().getItemInMainHand() != null) {
|
||||
|
||||
ItemStack is = p.getInventory().getItemInMainHand();
|
||||
if (is.getType() == Material.ENCHANTED_BOOK) {
|
||||
|
||||
EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) is.getItemMeta();
|
||||
for (Enchantment enchantment :
|
||||
enchantmentStorageMeta.getStoredEnchants().keySet()) {
|
||||
for (Enchantment enchantment : enchantmentStorageMeta.getStoredEnchants().keySet()) {
|
||||
|
||||
if (enchantment.equals(Enchantment.SILK_TOUCH)) {
|
||||
|
||||
if (e.getBlock().getType() == Material.CHEST
|
||||
|| e.getBlock().getType() == Material.TRAPPED_CHEST) {
|
||||
|| e.getBlock().getType() == Material.TRAPPED_CHEST)
|
||||
{
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
fListener
|
||||
.getLog()
|
||||
.append2(Msg.SilkTouchBookBlocked.getValue(
|
||||
p, e.getBlock().getType().name()));
|
||||
fListener.getLog()
|
||||
.append2(Msg.SilkTouchBookBlocked.getValue(p, e.getBlock().getType().name()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void LockMerchantTrades(InventoryOpenEvent e) {
|
||||
|
||||
if (Protections.PreventCommandsInBed.isEnabled(e.getPlayer())
|
||||
&& e.getPlayer().isSleeping()) {
|
||||
if (Protections.PreventCommandsInBed.isEnabled(e.getPlayer()) && e.getPlayer().isSleeping()) {
|
||||
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!Protections.VillagerTradeCheesing.isEnabled(e.getPlayer())) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (e.getInventory() instanceof MerchantInventory) {
|
||||
|
||||
MerchantInventory mi = (MerchantInventory) e.getInventory();
|
||||
if (mi.getHolder() instanceof WanderingTrader) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (mi.getHolder() instanceof Villager) {
|
||||
|
||||
Villager v = (Villager) mi.getHolder();
|
||||
|
||||
if (v.getVillagerExperience() == 0) {
|
||||
|
||||
v.setVillagerExperience(1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PreventVillagerRestock(VillagerReplenishTradeEvent e) {
|
||||
|
||||
if (!Protections.VillagerTradeCheesing.isEnabled(e.getEntity().getWorld())) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (Protections.VillagerRestockTime.getIntValue() <= 0 || !fListener.getIs114()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// if the villager is not in the list, add them with a new empty timestamp.
|
||||
if (!lastTrade.containsKey(e.getEntity().getUniqueId())) {
|
||||
|
||||
lastTrade.put(e.getEntity().getUniqueId(), 0L);
|
||||
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() >= lastTrade.get(e.getEntity().getUniqueId())) {
|
||||
|
||||
// timestamp is either empty or has expired, allow a restock.
|
||||
lastTrade.put(
|
||||
e.getEntity().getUniqueId(),
|
||||
lastTrade.put(e.getEntity().getUniqueId(),
|
||||
System.currentTimeMillis() + 60000L * Protections.VillagerRestockTime.getIntValue());
|
||||
|
||||
} else {
|
||||
|
||||
// timestamp has not expired do not allow restocking.
|
||||
e.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHandSwap(PlayerSwapHandItemsEvent e) {
|
||||
|
||||
if (!Protections.PreventFoodDupe.isEnabled(e.getPlayer())) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ItemStack item1 = e.getMainHandItem();
|
||||
ItemStack item2 = e.getOffHandItem();
|
||||
if (item1 == null || item2 == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
if (consumables.contains(item1.getType())
|
||||
&& consumables.contains(item2.getType())
|
||||
&& item1.getType() == item2.getType()) {
|
||||
|
||||
if (consumables.contains(item1.getType()) && consumables.contains(item2.getType())
|
||||
&& item1.getType() == item2.getType())
|
||||
{
|
||||
|
||||
if (item1.getAmount() == 1 && item2.getAmount() == 1) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR));
|
||||
e.setCancelled(true);
|
||||
Scheduler.runTaskLater(
|
||||
IllegalStack.getPlugin(),
|
||||
() -> {
|
||||
e.getPlayer().getInventory().setItemInMainHand(item1);
|
||||
e.getPlayer().getInventory().setItemInOffHand(item2);
|
||||
},
|
||||
3,
|
||||
e.getPlayer());
|
||||
Scheduler.runTaskLater(IllegalStack.getPlugin(), () -> {
|
||||
|
||||
e.getPlayer().getInventory().setItemInMainHand(item1);
|
||||
e.getPlayer().getInventory().setItemInOffHand(item2);
|
||||
|
||||
}, 3, e.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPortal(PortalCreateEvent event) {
|
||||
|
||||
if (Protections.PreventBedrockDestruction.isEnabled(event.getWorld())) {
|
||||
|
||||
for (BlockState b : event.getBlocks()) {
|
||||
|
||||
if (fListener.getUnbreakable().contains(b.getType())) {
|
||||
|
||||
// Blocking breaking of unbreakable blocks.
|
||||
LOGGER.info(
|
||||
"Portal tried to break an unbreakable block: {}",
|
||||
b.getType().name());
|
||||
LOGGER.info("Portal tried to break an unbreakable block: {}", b.getType().name());
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (b.getY() > b.getWorld().getMaxHeight()) {
|
||||
// Blocking portals spawning at world height limit, preventing from https://i.imgur.com/mqAXdpU.png
|
||||
|
||||
// Blocking portals spawning at world height limit, preventing from
|
||||
// https://i.imgur.com/mqAXdpU.png
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPearlHit(ProjectileHitEvent e) {
|
||||
|
||||
if (Protections.PreventPearlGlassPhasing.isEnabled(e.getEntity().getLocation())) {
|
||||
if (!(e.getEntity() instanceof EnderPearl)
|
||||
|| e.getHitBlock() == null
|
||||
|| !(e.getEntity().getShooter() instanceof Player)
|
||||
|| e.getHitBlockFace() != BlockFace.UP) {
|
||||
|
||||
if (!(e.getEntity() instanceof EnderPearl) || e.getHitBlock() == null
|
||||
|| !(e.getEntity().getShooter() instanceof Player) || e.getHitBlockFace() != BlockFace.UP)
|
||||
{
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
for (BlockFace face : faces) {
|
||||
|
||||
Block next = e.getHitBlock().getRelative(face);
|
||||
Block above = next.getRelative(BlockFace.UP);
|
||||
Player p = ((Player) e.getEntity().getShooter());
|
||||
if (!fListener.getAirBlocks().contains(above.getType())) {
|
||||
|
||||
if (!fListener.getInstance().getGlassBlocks().contains(above.getType())) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
Location l = e.getHitBlock()
|
||||
.getRelative(e.getHitBlockFace())
|
||||
.getLocation()
|
||||
.add(0.5, 0.5, 0.5);
|
||||
|
||||
Location l = e.getHitBlock().getRelative(e.getHitBlockFace()).getLocation().add(0.5, 0.5, 0.5);
|
||||
fListener.getInstance().getTeleGlitch().put(p.getUniqueId(), l);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemSwitch(PlayerItemHeldEvent e) {
|
||||
|
||||
if (!Protections.PreventFoodDupe.isEnabled(e.getPlayer())) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ItemStack item1 = e.getPlayer().getInventory().getItem(e.getPreviousSlot());
|
||||
ItemStack item2 = e.getPlayer().getInventory().getItem(e.getNewSlot());
|
||||
if (item1 == null || item2 == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (consumables.contains(item1.getType())
|
||||
&& consumables.contains(item2.getType())
|
||||
&& item1.getType() == item2.getType()) {
|
||||
if (consumables.contains(item1.getType()) && consumables.contains(item2.getType())
|
||||
&& item1.getType() == item2.getType())
|
||||
{
|
||||
|
||||
if (item1.getAmount() == 1 && item2.getAmount() == 1) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
int tSlot = e.getNewSlot();
|
||||
ItemStack tFood = e.getPlayer().getInventory().getItem(tSlot);
|
||||
if (tFood == null) {
|
||||
|
||||
tSlot = e.getPreviousSlot();
|
||||
tFood = e.getPlayer().getInventory().getItem(tSlot);
|
||||
|
||||
}
|
||||
|
||||
final int slot = tSlot;
|
||||
final ItemStack food = tFood;
|
||||
e.getPlayer().getInventory().setItem(slot, new ItemStack(Material.AIR));
|
||||
Scheduler.runTaskLater(
|
||||
IllegalStack.getPlugin(), () -> e.getPlayer().getInventory().setItem(slot, food), 3, e.getPlayer());
|
||||
Scheduler.runTaskLater(IllegalStack.getPlugin(), () -> e.getPlayer().getInventory().setItem(slot, food), 3,
|
||||
e.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent e) {
|
||||
if (e.getEntity() instanceof FishHook) return;
|
||||
|
||||
if (e.getEntity() instanceof FishHook)
|
||||
return;
|
||||
if (Protections.PreventProjectileExploit2.isEnabled(e.getEntity().getLocation())) {
|
||||
|
||||
fTimer.trackProjectile(e.getEntity());
|
||||
|
||||
}
|
||||
|
||||
if (Protections.PreventInvalidPotions.isEnabled() && e.getEntity() != null)
|
||||
e.setCancelled(BadPotionCheck.isInvalidPotion(e.getEntity()));
|
||||
|
||||
}
|
||||
|
||||
@EventHandler // (ignoreCancelled = false, priority=EventPriority.LOWEST)
|
||||
public void onFallingBlockSpawn(EntitySpawnEvent e) {
|
||||
if (e.getEntity() instanceof Projectile
|
||||
&& !(e.getEntity() instanceof FishHook)
|
||||
&& Protections.PreventProjectileExploit2.isEnabled(e.getEntity().getLocation())) {
|
||||
|
||||
if (e.getEntity() instanceof Projectile && !(e.getEntity() instanceof FishHook)
|
||||
&& Protections.PreventProjectileExploit2.isEnabled(e.getEntity().getLocation()))
|
||||
{
|
||||
|
||||
fTimer.trackProjectile((Projectile) e.getEntity());
|
||||
|
||||
}
|
||||
|
||||
if (!(e.getEntity() instanceof FallingBlock)
|
||||
|| !Protections.PreventVibratingBlocks.isEnabled(e.getLocation())) {
|
||||
|| !Protections.PreventVibratingBlocks.isEnabled(e.getLocation()))
|
||||
{
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
fTimer.trackBlock((FallingBlock) e.getEntity());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,29 +14,43 @@ public class Listener116 implements Listener {
|
||||
public Listener116(IllegalStack plugin) {
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||
|
||||
if (Protections.PreventPiglinDupe.isEnabled() && e.getEntity() instanceof Piglin) {
|
||||
|
||||
Piglin p = (Piglin) e.getEntity();
|
||||
p.setCanPickupItems(false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityPickup(EntityPickupItemEvent e) {
|
||||
|
||||
if (Protections.PreventPiglinDupe.isEnabled() && e.getEntity() instanceof Piglin) {
|
||||
|
||||
e.setCancelled(true);
|
||||
Piglin pig = (Piglin) e.getEntity();
|
||||
pig.setCanPickupItems(false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent e) {
|
||||
|
||||
if (Protections.PreventPiglinDupe.isEnabled() && e.getEntity() instanceof Piglin) {
|
||||
|
||||
e.getDrops().clear();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,87 +21,118 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
public class ProtectionListener implements Listener {
|
||||
|
||||
IllegalStack plugin;
|
||||
private static final Logger LOGGER =
|
||||
LogManager.getLogger("IllegalStack/" + ProtectionListener.class.getSimpleName());
|
||||
private static final Logger LOGGER = LogManager
|
||||
.getLogger("IllegalStack/" + ProtectionListener.class.getSimpleName());
|
||||
|
||||
public ProtectionListener(IllegalStack illegalStack) {
|
||||
|
||||
this.plugin = illegalStack;
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent e) {
|
||||
|
||||
if (!Protections.PreventItemSwapLagExploit.isEnabled()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!fListener.getInstance().getSwapDelay().containsKey(e.getPlayer())) {
|
||||
|
||||
fListener.getInstance().getSwapDelay().put(e.getPlayer(), 0L);
|
||||
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() < fListener.getInstance().getSwapDelay().get(e.getPlayer())) {
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
} else {
|
||||
|
||||
fListener.getInstance().getSwapDelay().put(e.getPlayer(), System.currentTimeMillis() + 750L);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onElytraFlight(EntityToggleGlideEvent e) {
|
||||
|
||||
if (Protections.PreventInfiniteElytraFlight.isEnabled() && e.isGliding() && e.getEntity() instanceof Player) {
|
||||
|
||||
Player p = (Player) e.getEntity();
|
||||
if (p.getLocation().getBlockY() >= 255) {
|
||||
|
||||
fListener.getLog().append2(Msg.GlideActivateMaxBuild.getValue(p, ""));
|
||||
p.setGliding(false);
|
||||
e.setCancelled(true);
|
||||
|
||||
}
|
||||
Scheduler.runTaskLater(
|
||||
this.plugin,
|
||||
() -> {
|
||||
if (p.getLocation().getBlockY() > 255 && p.isGliding()) {
|
||||
fListener.getLog().append2(Msg.GlideAboveMaxBuild.getValue(p, ""));
|
||||
p.setGliding(false);
|
||||
}
|
||||
},
|
||||
3250,
|
||||
p);
|
||||
|
||||
Scheduler.runTaskLater(this.plugin, () -> {
|
||||
|
||||
if (p.getLocation().getBlockY() > 255 && p.isGliding()) {
|
||||
|
||||
fListener.getLog().append2(Msg.GlideAboveMaxBuild.getValue(p, ""));
|
||||
p.setGliding(false);
|
||||
|
||||
}
|
||||
|
||||
}, 3250, p);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockForm(BlockFormEvent e) {
|
||||
|
||||
if (!Protections.PreventCobbleGenerators.isEnabled()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (e.getNewState().getType() == Material.COBBLESTONE) {
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRepairAttempt(PrepareAnvilEvent e) {
|
||||
|
||||
if (Protections.BlockRepairsInstead.isEnabled()) {
|
||||
|
||||
ItemStack is = e.getResult();
|
||||
if (NBTStuff.hasNbtTag("IllegalStack", is, "NoRepair", Protections.BlockRepairsInstead)) {
|
||||
|
||||
e.setResult(new ItemStack(Material.AIR, 1));
|
||||
e.getView().close();
|
||||
fListener
|
||||
.getLog()
|
||||
.append2(Msg.PlayerRepairBlocked.getValue(
|
||||
e.getView().getPlayer().getName()));
|
||||
fListener.getLog().append2(Msg.PlayerRepairBlocked.getValue(e.getView().getPlayer().getName()));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (is != null && is.hasItemMeta()) {
|
||||
|
||||
ItemMeta im = is.getItemMeta();
|
||||
if (Protections.RemoveItemsMatchingName.loreNameMatch(im)) {
|
||||
|
||||
e.setResult(new ItemStack(Material.AIR, 1));
|
||||
e.getView().close();
|
||||
fListener
|
||||
.getLog()
|
||||
.append2(Msg.PlayerRepairBlocked.getValue(
|
||||
e.getView().getPlayer().getName()));
|
||||
fListener.getLog().append2(Msg.PlayerRepairBlocked.getValue(e.getView().getPlayer().getName()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -15,55 +15,58 @@ public class mcMMOListener implements Listener {
|
||||
private final IllegalStack plugin;
|
||||
|
||||
public mcMMOListener(IllegalStack illegalStack) {
|
||||
|
||||
this.plugin = illegalStack;
|
||||
|
||||
}
|
||||
|
||||
public static boolean ismcMMOActive(Player player) {
|
||||
|
||||
if (mcMMOactive == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return mcMMOactive.contains(player.getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@EventHandler
|
||||
public void onPotionBrew(McMMOPlayerBrewEvent e) {
|
||||
BrewingStand bs =(BrewingStand) e.getBrewingStand();
|
||||
ItemStack[] storageContents = bs.getInventory().getStorageContents();
|
||||
for(int i = 0; i < storageContents.length;i++) {
|
||||
ItemStack is = storageContents[i];
|
||||
|
||||
if(is == null)
|
||||
continue;
|
||||
|
||||
if(is.getType() == Material.POTION || is.getType() == Material.SPLASH_POTION)
|
||||
{
|
||||
int slot = i;
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
bs.getInventory().setItem(slot, NBTStuff.addNBTTag(is, "mcmmoitem"));
|
||||
|
||||
}
|
||||
}.runTaskLater(this.plugin, 12);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
* @EventHandler public void onPotionBrew(McMMOPlayerBrewEvent e) { BrewingStand
|
||||
* bs =(BrewingStand) e.getBrewingStand(); ItemStack[] storageContents =
|
||||
* bs.getInventory().getStorageContents(); for(int i = 0; i <
|
||||
* storageContents.length;i++) { ItemStack is = storageContents[i];
|
||||
*
|
||||
* if(is == null) continue;
|
||||
*
|
||||
* if(is.getType() == Material.POTION || is.getType() == Material.SPLASH_POTION)
|
||||
* { int slot = i;
|
||||
*
|
||||
* new BukkitRunnable() {
|
||||
*
|
||||
* @Override public void run() {
|
||||
*
|
||||
* bs.getInventory().setItem(slot, NBTStuff.addNBTTag(is, "mcmmoitem"));
|
||||
*
|
||||
* } }.runTaskLater(this.plugin, 12);
|
||||
*
|
||||
* }
|
||||
*
|
||||
* } }
|
||||
*/
|
||||
@EventHandler
|
||||
public void onAbilActivate(McMMOPlayerAbilityActivateEvent e) {
|
||||
|
||||
mcMMOactive.add(e.getPlayer().getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAbilDeactivate(McMMOPlayerAbilityDeactivateEvent e) {
|
||||
|
||||
mcMMOactive.remove(e.getPlayer().getUniqueId());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,136 +30,169 @@ public class pLisbListener {
|
||||
HashMap<UUID, Long> messageDelay = new HashMap<>();
|
||||
|
||||
public pLisbListener(IllegalStack illegalStack) {
|
||||
|
||||
plugin = illegalStack;
|
||||
|
||||
// ProtocolLibrary.getProtocolManager().addPacketListener(new BookCrashExploitCheck(plugin));
|
||||
// ProtocolLibrary.getProtocolManager().addPacketListener(new
|
||||
// BookCrashExploitCheck(plugin));
|
||||
if (Protections.BlockBadItemsFromCreativeTab.isEnabled()) {
|
||||
ProtocolLibrary.getProtocolManager()
|
||||
.addPacketListener(
|
||||
new PacketAdapter(PacketAdapter.params(plugin, PacketType.Play.Client.SET_CREATIVE_SLOT)
|
||||
.optionAsync()) {
|
||||
// new PacketAdapter(plugin, PacketType.Play.Client.SET_CREATIVE_SLOT) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
if (!Protections.BlockBadItemsFromCreativeTab.isEnabled()
|
||||
|| event.getPlayer().isOp()
|
||||
|| event.getPlayer().hasPermission("illegalstack.admin")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ItemStack stack = event.getPacket()
|
||||
.getItemModifier()
|
||||
.readSafely(0);
|
||||
if (stack != null && stack.hasItemMeta()) {
|
||||
stack = new ItemStack(Material.AIR);
|
||||
final Player player = event.getPlayer();
|
||||
Scheduler.runTaskLater(plugin, player::updateInventory, 5L, player);
|
||||
event.setCancelled(true);
|
||||
Msg.StaffMsgCreativeBlock.getValue(
|
||||
event.getPlayer().getName());
|
||||
}
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
LOGGER.error(
|
||||
"An error receiving a SET_CREATIVE_SLOT packet has occurred, you are probably using paper and have BlockBadItemsFromCreativeTab turned on. This setting is needed very rarely, and ONLY if you have regular non-op players with access to /gmc.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(
|
||||
PacketAdapter.params(plugin, PacketType.Play.Client.SET_CREATIVE_SLOT).optionAsync())
|
||||
{
|
||||
|
||||
// new PacketAdapter(plugin, PacketType.Play.Client.SET_CREATIVE_SLOT) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
|
||||
if (!Protections.BlockBadItemsFromCreativeTab.isEnabled() || event.getPlayer().isOp()
|
||||
|| event.getPlayer().hasPermission("illegalstack.admin"))
|
||||
{
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
ItemStack stack = event.getPacket().getItemModifier().readSafely(0);
|
||||
if (stack != null && stack.hasItemMeta()) {
|
||||
|
||||
stack = new ItemStack(Material.AIR);
|
||||
final Player player = event.getPlayer();
|
||||
Scheduler.runTaskLater(plugin, player::updateInventory, 5L, player);
|
||||
event.setCancelled(true);
|
||||
Msg.StaffMsgCreativeBlock.getValue(event.getPlayer().getName());
|
||||
|
||||
}
|
||||
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
|
||||
LOGGER.error(
|
||||
"An error receiving a SET_CREATIVE_SLOT packet has occurred, you are probably using paper and have BlockBadItemsFromCreativeTab turned on. This setting is needed very rarely, and ONLY if you have regular non-op players with access to /gmc.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (Protections.DisableChestsOnMobs.isEnabled()) {
|
||||
|
||||
ProtocolLibrary.getProtocolManager()
|
||||
.addPacketListener(
|
||||
new PacketAdapter(PacketAdapter.params(plugin, PacketType.Play.Client.USE_ENTITY)
|
||||
.optionAsync()) {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(
|
||||
new PacketAdapter(PacketAdapter.params(plugin, PacketType.Play.Client.USE_ENTITY).optionAsync())
|
||||
{
|
||||
|
||||
/*
|
||||
* Must use optionAsync here... if optionSync is used it breaks player damage, eg no crits, no sweeping edge...
|
||||
*
|
||||
* new PacketAdapter(PacketAdapter.params().plugin(plugin).optionSync().types(PacketType.Play.Client.USE_ENTITY)) {
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Must use optionAsync here... if optionSync is used it breaks player damage,
|
||||
* eg no crits, no sweeping edge...
|
||||
*
|
||||
* new PacketAdapter(PacketAdapter.params().plugin(plugin).optionSync().types(
|
||||
* PacketType.Play.Client.USE_ENTITY)) {
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
|
||||
if (event.getPacket().getIntegers().read(0) <= 0) {
|
||||
return;
|
||||
}
|
||||
if (event.getPacket().getIntegers().read(0) <= 0) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (IllegalStack.hasChestedAnimals() && Protections.DisableChestsOnMobs.isEnabled()) {
|
||||
|
||||
Entity entity;
|
||||
try {
|
||||
|
||||
entity = event.getPacket().getEntityModifier(event.getPlayer().getWorld()).read(0);
|
||||
|
||||
} catch (RuntimeException ex) {
|
||||
|
||||
// LOGGER.error("Async Packet - Couldn't get an entity from id: ", ex);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Scheduler.runTaskLater(this.plugin, () -> {
|
||||
|
||||
if (entity instanceof Horse && ((Horse) entity).isTamed()) {
|
||||
|
||||
ItemStack is = event.getPlayer().getInventory().getItemInHand();
|
||||
if (!fListener.is18() && (is == null || is.getType() != Material.CHEST)) {
|
||||
|
||||
is = event.getPlayer().getInventory().getItemInOffHand();
|
||||
|
||||
if (IllegalStack.hasChestedAnimals()
|
||||
&& Protections.DisableChestsOnMobs.isEnabled()) {
|
||||
Entity entity;
|
||||
try {
|
||||
entity = event.getPacket()
|
||||
.getEntityModifier(
|
||||
event.getPlayer().getWorld())
|
||||
.read(0);
|
||||
} catch (RuntimeException ex) {
|
||||
// LOGGER.error("Async Packet - Couldn't get an entity from id: ", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
Scheduler.runTaskLater(
|
||||
this.plugin,
|
||||
() -> {
|
||||
if (entity instanceof Horse && ((Horse) entity).isTamed()) {
|
||||
ItemStack is = event.getPlayer()
|
||||
.getInventory()
|
||||
.getItemInHand();
|
||||
if (!fListener.is18()
|
||||
&& (is == null || is.getType() != Material.CHEST)) {
|
||||
is = event.getPlayer()
|
||||
.getInventory()
|
||||
.getItemInOffHand();
|
||||
}
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
return;
|
||||
}
|
||||
exploitMessage(event.getPlayer(), entity);
|
||||
event.setCancelled(true);
|
||||
fTimer.getPunish().put(event.getPlayer(), entity);
|
||||
return;
|
||||
}
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
|
||||
if (entity instanceof ChestedHorse
|
||||
&& ((ChestedHorse) entity).isTamed()) {
|
||||
ItemStack is = event.getPlayer()
|
||||
.getInventory()
|
||||
.getItemInMainHand();
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
is = event.getPlayer()
|
||||
.getInventory()
|
||||
.getItemInOffHand();
|
||||
}
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
return;
|
||||
}
|
||||
exploitMessage(event.getPlayer(), entity);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
exploitMessage(event.getPlayer(), entity);
|
||||
event.setCancelled(true);
|
||||
fTimer.getPunish().put(event.getPlayer(), entity);
|
||||
return;
|
||||
|
||||
((ChestedHorse) entity).setCarryingChest(true);
|
||||
((ChestedHorse) entity).setCarryingChest(false);
|
||||
fTimer.getPunish().put(event.getPlayer(), entity);
|
||||
}
|
||||
},
|
||||
1,
|
||||
entity);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (entity instanceof ChestedHorse && ((ChestedHorse) entity).isTamed()) {
|
||||
|
||||
ItemStack is = event.getPlayer().getInventory().getItemInMainHand();
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
|
||||
is = event.getPlayer().getInventory().getItemInOffHand();
|
||||
|
||||
}
|
||||
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
exploitMessage(event.getPlayer(), entity);
|
||||
event.setCancelled(true);
|
||||
|
||||
((ChestedHorse) entity).setCarryingChest(true);
|
||||
((ChestedHorse) entity).setCarryingChest(false);
|
||||
fTimer.getPunish().put(event.getPlayer(), entity);
|
||||
|
||||
}
|
||||
|
||||
}, 1, entity);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void exploitMessage(Player p, Entity ent) {
|
||||
|
||||
if (!messageDelay.containsKey(p.getUniqueId())) {
|
||||
|
||||
messageDelay.put(p.getUniqueId(), 0L);
|
||||
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > messageDelay.get(p.getUniqueId())) {
|
||||
|
||||
p.sendMessage(Msg.PlayerDisabledHorseChestMsg.getValue());
|
||||
fListener.getLog().append2(Msg.ChestPrevented.getValue(p, ent));
|
||||
messageDelay.put(p.getUniqueId(), System.currentTimeMillis() + 2000L);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,92 +28,131 @@ public class Log {
|
||||
File file;
|
||||
|
||||
public Log(IllegalStack plugin) {
|
||||
|
||||
this.plugin = plugin;
|
||||
if (Protections.LogOffensesInSeparateFile.isEnabled()) {
|
||||
|
||||
file = new File(plugin.getDataFolder() + "/OffenseLog.txt");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void append2(String message) {
|
||||
|
||||
this.append(message, null);
|
||||
|
||||
}
|
||||
|
||||
public void append(String message, Protections prot) {
|
||||
|
||||
if (prot != null) {
|
||||
|
||||
IllegalStackLogEvent event = new IllegalStackLogEvent(message, prot);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Protections.LogOffensesInSeparateFile.isEnabled()) {
|
||||
|
||||
try {
|
||||
|
||||
IllegalStack.getLogger(message);
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(file, true));
|
||||
bw.append(dateStamp() + " - ").append(message).append("\r\n");
|
||||
bw.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
IllegalStack.getLogger(message);
|
||||
|
||||
}
|
||||
|
||||
if (Protections.InGameNotifications.isEnabled()) {
|
||||
|
||||
for (Player p : IllegalStack.getPlugin().getServer().getOnlinePlayers()) {
|
||||
|
||||
if (p.hasPermission("illegalstack.notify")) {
|
||||
|
||||
message = cleanMessage(message);
|
||||
|
||||
if (IllegalStack.isSpigot() && message.contains("@")) {
|
||||
|
||||
TextComponent msg = new TextComponent(message);
|
||||
msg.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(Msg.PluginTeleportText.getValue()).create()));
|
||||
msg.setClickEvent(new ClickEvent(Action.RUN_COMMAND, getTeleportLoc(message)));
|
||||
p.spigot().sendMessage(msg);
|
||||
|
||||
} else {
|
||||
|
||||
p.sendMessage(Msg.PluginPrefix.getValue() + ChatColor.RESET + message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getTeleportLoc(String message) {
|
||||
|
||||
String[] words = message.split("@");
|
||||
String[] coords = words[1].split(" ");
|
||||
String position = "";
|
||||
|
||||
try {
|
||||
|
||||
int x = Integer.parseInt(coords[2]);
|
||||
int y = Integer.parseInt(coords[3]);
|
||||
int z = Integer.parseInt(coords[4]);
|
||||
position = "/istack teleport " + x + " " + y + " " + z + " " + ChatColor.stripColor(coords[1]);
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
IllegalStack.getLogger("Failed to get position");
|
||||
for (int i = 0; i < coords.length; i++) {
|
||||
|
||||
IllegalStack.getLogger("Coord: " + i + " " + coords[i]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return position;
|
||||
|
||||
}
|
||||
|
||||
public String cleanMessage(String message) {
|
||||
|
||||
if (message.contains("@Location{") || message.contains("@ Location{")) {
|
||||
|
||||
String msg = message.substring(message.indexOf('@'));
|
||||
String[] words = msg.split(",");
|
||||
String[] wld = words[0].split("name=");
|
||||
|
||||
msg = wld[0].split("@")[0];
|
||||
/*
|
||||
for(int i = 0; i < words.length;i++)
|
||||
|
||||
for(int i = 0; i < wld.length;i++)
|
||||
*/
|
||||
* for(int i = 0; i < words.length;i++)
|
||||
*
|
||||
* for(int i = 0; i < wld.length;i++)
|
||||
*/
|
||||
|
||||
String world = wld[1].substring(0, wld[1].indexOf("}"));
|
||||
int x = (int) Double.parseDouble(words[1].substring(2));
|
||||
@@ -121,66 +160,95 @@ public class Log {
|
||||
int z = (int) Double.parseDouble(words[3].substring(2));
|
||||
|
||||
if (Protections.PlayerOffenseNotifications.isEnabled()) {
|
||||
|
||||
World w = IllegalStack.getPlugin().getServer().getWorld(world);
|
||||
Location offense = new Location(w, x, y, z);
|
||||
for (Player p : w.getPlayers()) {
|
||||
|
||||
if (p.getLocation().distance(offense) <= 10) {
|
||||
|
||||
// [IllegalStack] -Stopped Retraction Dupe Glitch & Removed Piston @
|
||||
// Location{world=CraftWorld{name=event},x=-266.0,y=81.0,z=-238.0,pitch=0.0,yaw=0.0}
|
||||
String mNear = message.substring(0, message.indexOf('@'));
|
||||
mNear = Msg.PluginPrefix.getValue() + " " + Msg.PlayerNearbyNotification.getValue(mNear);
|
||||
p.sendMessage(mNear);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String coords = "@ " + ChatColor.AQUA + world + " " + x + " " + y + " " + z;
|
||||
// message = message + " @ " + ChatColor.AQUA + world + " " + x + " " + y + " " + z;
|
||||
// message = message + " @ " + ChatColor.AQUA + world + " " + x + " " + y + " "
|
||||
// + z;
|
||||
message = message.substring(0, message.indexOf('@')) + " " + coords;
|
||||
|
||||
}
|
||||
|
||||
return message;
|
||||
|
||||
}
|
||||
|
||||
public String dateStamp() {
|
||||
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
return dateFormat.format(date);
|
||||
|
||||
}
|
||||
|
||||
public void notify(Protections prot, String message) {
|
||||
|
||||
if (Protections.LogOffensesInSeparateFile.isEnabled()) {
|
||||
|
||||
try {
|
||||
|
||||
IllegalStack.getLogger("(Notification Only) " + prot.name() + " " + message);
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(file, true));
|
||||
bw.append(dateStamp()).append(message).append("\r\n");
|
||||
bw.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
IllegalStack.getLogger("(Notification Only) " + message);
|
||||
|
||||
}
|
||||
|
||||
if (Protections.LogOffensesInSeparateFile.isEnabled()) {
|
||||
|
||||
for (Player p : IllegalStack.getPlugin().getServer().getOnlinePlayers()) {
|
||||
|
||||
if (p.hasPermission("illegalstack.notify")) {
|
||||
|
||||
message = cleanMessage(message);
|
||||
|
||||
if (IllegalStack.isSpigot() && message.contains("@")) {
|
||||
|
||||
TextComponent msg = new TextComponent(ChatColor.GREEN + "(Notification Only) " + message);
|
||||
msg.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(Msg.PluginTeleportText.getValue()).create()));
|
||||
msg.setClickEvent(new ClickEvent(Action.RUN_COMMAND, getTeleportLoc(message)));
|
||||
p.spigot().sendMessage(msg);
|
||||
|
||||
} else {
|
||||
|
||||
p.sendMessage(
|
||||
ChatColor.RED + "[IllegalStack] - (Notification Only)" + ChatColor.RESET + message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -31,122 +31,174 @@ public class sTimer implements Runnable {
|
||||
private static boolean scanChunks = false;
|
||||
|
||||
public sTimer() {
|
||||
|
||||
if (Protections.DestroyBadSignsonChunkLoad.isEnabled()) {
|
||||
|
||||
scanChunks = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static long getSignCheck() {
|
||||
|
||||
return signCheck;
|
||||
|
||||
}
|
||||
|
||||
public static void setSignCheck(long signCheck) {
|
||||
|
||||
sTimer.signCheck = signCheck;
|
||||
|
||||
}
|
||||
|
||||
public static void checkSign(Block block, Player player) {
|
||||
|
||||
signBlock.put(block, player);
|
||||
if (signCheck == -1L) {
|
||||
|
||||
signCheck = System.currentTimeMillis() + 4000L;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void checkChunk(String chunkID, BlockState[] tileEntities) {
|
||||
|
||||
if (!checkedChunks.contains(chunkID)) {
|
||||
|
||||
entList.add(tileEntities);
|
||||
checkedChunks.add(chunkID);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (!IllegalStack.isIsHybridEnvironment()
|
||||
&& IllegalStack.isPaperServer()
|
||||
&& IllegalStack.getMajorServerVersion() >= 16) {
|
||||
if (!IllegalStack.isIsHybridEnvironment() && IllegalStack.isPaperServer()
|
||||
&& IllegalStack.getMajorServerVersion() >= 16)
|
||||
{
|
||||
|
||||
if (IllegalStack.isDisable() || Bukkit.getServer().isStopping()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (IllegalStack.isDisable()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!Protections.DestroyBadSignsonChunkLoad.isEnabled()
|
||||
|| Protections.DestroyBadSignsonChunkLoad.notifyOnly()) {
|
||||
return;
|
||||
}
|
||||
if (getSignCheck() != -1L && System.currentTimeMillis() >= getSignCheck()) {
|
||||
for (Block b : signBlock.keySet()) {
|
||||
Scheduler.executeOrScheduleSync(
|
||||
IllegalStack.getPlugin(),
|
||||
() -> {
|
||||
BlockState st = b.getState();
|
||||
if (st instanceof Sign) {
|
||||
Sign sign = (Sign) st;
|
||||
boolean illegal = false;
|
||||
for (String line : sign.getLines()) {
|
||||
if (!Charset.forName(Protections.ValidCharset.getTxtValue())
|
||||
.newEncoder()
|
||||
.canEncode(ChatColor.stripColor(line))) {
|
||||
illegal = true;
|
||||
LOGGER.info(
|
||||
"Found a sign with illegal chars: line with invalid text was: {} @ {}",
|
||||
line,
|
||||
sign.getLocation().toString());
|
||||
}
|
||||
}
|
||||
|| Protections.DestroyBadSignsonChunkLoad.notifyOnly())
|
||||
{
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (getSignCheck() != -1L && System.currentTimeMillis() >= getSignCheck()) {
|
||||
|
||||
for (Block b : signBlock.keySet()) {
|
||||
|
||||
Scheduler.executeOrScheduleSync(IllegalStack.getPlugin(), () -> {
|
||||
|
||||
BlockState st = b.getState();
|
||||
if (st instanceof Sign) {
|
||||
|
||||
Sign sign = (Sign) st;
|
||||
boolean illegal = false;
|
||||
for (String line : sign.getLines()) {
|
||||
|
||||
if (!Charset.forName(Protections.ValidCharset.getTxtValue()).newEncoder()
|
||||
.canEncode(ChatColor.stripColor(line)))
|
||||
{
|
||||
|
||||
illegal = true;
|
||||
LOGGER.info("Found a sign with illegal chars: line with invalid text was: {} @ {}",
|
||||
line, sign.getLocation().toString());
|
||||
|
||||
Player p = signBlock.get(sign.getBlock());
|
||||
if (illegal) {
|
||||
if (p != null) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append2(Msg.SignRemovedOnPlace.getValue(
|
||||
sign.getLocation(),
|
||||
signBlock.get(b).getName()));
|
||||
}
|
||||
sign.getBlock().setType(Material.AIR);
|
||||
p.kickPlayer(Msg.SignKickPlayerMsg.getValue());
|
||||
}
|
||||
}
|
||||
},
|
||||
b.getLocation());
|
||||
|
||||
}
|
||||
|
||||
Player p = signBlock.get(sign.getBlock());
|
||||
if (illegal) {
|
||||
|
||||
if (p != null) {
|
||||
|
||||
fListener.getLog().append2(Msg.SignRemovedOnPlace.getValue(sign.getLocation(),
|
||||
signBlock.get(b).getName()));
|
||||
|
||||
}
|
||||
|
||||
sign.getBlock().setType(Material.AIR);
|
||||
p.kickPlayer(Msg.SignKickPlayerMsg.getValue());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}, b.getLocation());
|
||||
|
||||
}
|
||||
|
||||
signBlock.clear();
|
||||
setSignCheck(-1L);
|
||||
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() >= chunkScan && scanChunks) {
|
||||
|
||||
HashSet<Block> found = new HashSet<>();
|
||||
for (BlockState[] bs : entList) {
|
||||
|
||||
for (BlockState st : bs) {
|
||||
|
||||
if (st instanceof Sign) {
|
||||
|
||||
Sign sign = (Sign) st;
|
||||
for (String line : sign.getLines()) {
|
||||
if (!Charset.forName(Protections.ValidCharset.getTxtValue())
|
||||
.newEncoder()
|
||||
.canEncode(ChatColor.stripColor(line))) {
|
||||
Scheduler.executeOrScheduleSync(
|
||||
IllegalStack.getPlugin(),
|
||||
() -> sign.getBlock().setType(Material.AIR),
|
||||
sign.getLocation());
|
||||
|
||||
if (!Charset.forName(Protections.ValidCharset.getTxtValue()).newEncoder()
|
||||
.canEncode(ChatColor.stripColor(line)))
|
||||
{
|
||||
|
||||
Scheduler.executeOrScheduleSync(IllegalStack.getPlugin(),
|
||||
() -> sign.getBlock().setType(Material.AIR), sign.getLocation());
|
||||
found.add(sign.getBlock());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!found.isEmpty()) {
|
||||
|
||||
for (Block b : found) {
|
||||
|
||||
fListener.getLog().append2(Msg.SignRemoved.getValue(b.getLocation(), ""));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
chunkScan = System.currentTimeMillis() + 5000L;
|
||||
entList.clear();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,39 +16,57 @@ public class syncTimer implements Runnable {
|
||||
private static Set<Entity> entitiesToRemove = new HashSet<Entity>();
|
||||
|
||||
public syncTimer(IllegalStack illegalStack) {
|
||||
|
||||
this.plugin = illegalStack;
|
||||
this.nextScan = System.currentTimeMillis() + (scanDelay * 1000);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (!IllegalStack.isIsHybridEnvironment()
|
||||
&& IllegalStack.isPaperServer()
|
||||
&& IllegalStack.getMajorServerVersion() >= 16) {
|
||||
if (!IllegalStack.isIsHybridEnvironment() && IllegalStack.isPaperServer()
|
||||
&& IllegalStack.getMajorServerVersion() >= 16)
|
||||
{
|
||||
|
||||
if (IllegalStack.isDisable() || Bukkit.getServer().isStopping()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (IllegalStack.isDisable()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() >= nextScan) {
|
||||
|
||||
TrackedProjectile.manage();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void removeEntity(Entity ent) {
|
||||
|
||||
getEntitiesToRemove().add(ent);
|
||||
|
||||
}
|
||||
|
||||
public static Set<Entity> getEntitiesToRemove() {
|
||||
|
||||
return entitiesToRemove;
|
||||
|
||||
}
|
||||
|
||||
public static void setEntitiesToRemove(Set<Entity> entitiesToRemove) {
|
||||
|
||||
syncTimer.entitiesToRemove = entitiesToRemove;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,31 +11,43 @@ import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.ThrowableProjectile;
|
||||
|
||||
public class TrackedProjectile {
|
||||
|
||||
private static final Set<TrackedProjectile> trackedProjectiles = new HashSet<TrackedProjectile>();
|
||||
private Long despawnTimestamp = 0l;
|
||||
private Entity entity;
|
||||
|
||||
public TrackedProjectile(Projectile proj) {
|
||||
|
||||
if (alreadyTracked(proj) || !shouldTrack(proj)) return;
|
||||
if (alreadyTracked(proj) || !shouldTrack(proj))
|
||||
return;
|
||||
|
||||
entity = proj;
|
||||
despawnTimestamp = System.currentTimeMillis() + (Protections.ProjectileDespawnDelay.getIntValue() * 1000);
|
||||
trackedProjectiles.add(this);
|
||||
|
||||
}
|
||||
|
||||
private boolean shouldTrack(Projectile proj) {
|
||||
|
||||
if (proj != null) {
|
||||
if (proj instanceof Arrow || proj instanceof ThrowableProjectile) return true;
|
||||
|
||||
if (proj instanceof Arrow || proj instanceof ThrowableProjectile)
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean alreadyTracked(Entity ent) {
|
||||
|
||||
for (TrackedProjectile tp : trackedProjectiles) if (ent.equals(tp.entity)) return true;
|
||||
for (TrackedProjectile tp : trackedProjectiles)
|
||||
if (ent.equals(tp.entity))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static void manage() {
|
||||
@@ -43,52 +55,68 @@ public class TrackedProjectile {
|
||||
Set<TrackedProjectile> removed = new HashSet<>();
|
||||
|
||||
for (TrackedProjectile tp : trackedProjectiles) {
|
||||
|
||||
if (System.currentTimeMillis() > tp.despawnTimestamp) {
|
||||
|
||||
// projectile has expired remove it.
|
||||
if (tp.entity != null) {
|
||||
tp.entity
|
||||
.getScheduler()
|
||||
.run(
|
||||
IllegalStack.getPlugin(),
|
||||
task -> {
|
||||
removed.add(tp);
|
||||
tp.entity.remove();
|
||||
},
|
||||
null);
|
||||
|
||||
tp.entity.getScheduler().run(IllegalStack.getPlugin(), task -> {
|
||||
|
||||
removed.add(tp);
|
||||
tp.entity.remove();
|
||||
|
||||
}, null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
trackedProjectiles.removeAll(removed);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* I cannot figure out why this will not work async. Doing this async always seems to result in the server crashing..
|
||||
* I suspected the problem was due to the ProjectileLaunchEvent is fired twice whenever a projectile is launched, this seemed to be
|
||||
* causing 4 objects to get tracked when 2 were fired.. However the crash persists whenever I try to do this async it pukes.
|
||||
* Nothing that is going on here is difficult to do sync. I have moved this to a sync timer and it works flawlessly...
|
||||
* I cannot figure out why this will not work async. Doing this async always
|
||||
* seems to result in the server crashing.. I suspected the problem was due to
|
||||
* the ProjectileLaunchEvent is fired twice whenever a projectile is launched,
|
||||
* this seemed to be causing 4 objects to get tracked when 2 were fired..
|
||||
* However the crash persists whenever I try to do this async it pukes. Nothing
|
||||
* that is going on here is difficult to do sync. I have moved this to a sync
|
||||
* timer and it works flawlessly...
|
||||
*/
|
||||
public static void manageAsync() {
|
||||
|
||||
Set<TrackedProjectile> removed = new HashSet<>();
|
||||
|
||||
for (TrackedProjectile tp : trackedProjectiles) {
|
||||
|
||||
if (System.currentTimeMillis() > tp.despawnTimestamp) {
|
||||
|
||||
// projectile has expired remove it.
|
||||
if (tp.entity != null) {
|
||||
|
||||
removed.add(tp);
|
||||
Entity remove = tp.entity;
|
||||
// tp.entity.remove();
|
||||
Scheduler.executeOrScheduleSync(
|
||||
IllegalStack.getPlugin(),
|
||||
() -> {
|
||||
remove.remove();
|
||||
},
|
||||
remove);
|
||||
// tp.entity.remove();
|
||||
Scheduler.executeOrScheduleSync(IllegalStack.getPlugin(), () -> {
|
||||
|
||||
remove.remove();
|
||||
|
||||
}, remove);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// IllegalStack.getLogger("There are " + trackedProjectiles.size() + " projectiles being tracked");
|
||||
|
||||
// IllegalStack.getLogger("There are " + trackedProjectiles.size() + "
|
||||
// projectiles being tracked");
|
||||
trackedProjectiles.removeAll(removed);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,28 +11,41 @@ import org.bukkit.plugin.Plugin;
|
||||
public class BookCrashExploitCheck extends PacketAdapter {
|
||||
|
||||
public BookCrashExploitCheck(final Plugin plugin) {
|
||||
|
||||
super(plugin, PacketType.Play.Client.WINDOW_CLICK);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketReceiving(final PacketEvent event) {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
StructureModifier<Integer> integers = event.getPacket().getIntegers();
|
||||
|
||||
if (player != null) {
|
||||
|
||||
final InventoryView inventoryView = event.getPlayer().getOpenInventory();
|
||||
|
||||
if (inventoryView != null && integers.size() > 1) {
|
||||
|
||||
final int slot = integers.read(1) - 3;
|
||||
final int maxSlots = inventoryView.countSlots();
|
||||
PacketAttack pa = PacketAttack.findPlayer(player.getUniqueId());
|
||||
if (slot > maxSlots || slot < 0) {
|
||||
|
||||
event.setCancelled(pa.addAttempt(event, "WINDOW_INVALID_CLICK"));
|
||||
|
||||
} else {
|
||||
|
||||
event.setCancelled(pa.addAttempt(event, "WINDOW_CLICK_SPAM"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // else
|
||||
// event.setCancelled(true);
|
||||
// event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,73 +1,58 @@
|
||||
package main.java.me.dniym.utils;
|
||||
/*
|
||||
package main.java.me.dniym.utils;
|
||||
|
||||
public class DropExploit {
|
||||
private static final HashSet<DropExploit> trackedBlocks = new HashSet<>();
|
||||
private final Block block;
|
||||
private final HashMap<ItemStack, Long> items = new HashMap<>();
|
||||
private final int id = 0;
|
||||
|
||||
public DropExploit(Block block) {
|
||||
this.block = block;
|
||||
trackedBlocks.add(this);
|
||||
}
|
||||
|
||||
public static DropExploit findBlock(Block block) {
|
||||
|
||||
for (DropExploit de : trackedBlocks)
|
||||
if (de.block.equals(block))
|
||||
return de;
|
||||
return new DropExploit(block);
|
||||
}
|
||||
|
||||
public boolean tick(ItemStack item) {
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
|
||||
//if( !nbti.hasKey("TimeStamp")) {
|
||||
if (nbti.getLong("TimeStamp") == null || nbti.getLong("TimeStamp") == 0) {
|
||||
nbti.setLong("TimeStamp", System.currentTimeMillis() + 2500L);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() >= nbti.getLong("TimeStamp")) {
|
||||
nbti.setLong("TimeStamp", System.currentTimeMillis() + 2500L);
|
||||
return false;
|
||||
}
|
||||
fListener.getLog().append2(Msg.StaffMsgDropperExploit.getValue(block.getLocation().toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean tick(ItemStack item) {
|
||||
|
||||
NamespacedKey ts = new NamespacedKey(IllegalStack.getPlugin(), "timeStamp");
|
||||
|
||||
if (!item.hasItemMeta() || !item.getItemMeta().getPersistentDataContainer().has(ts, PersistentDataType.LONG)) {
|
||||
if (item.hasItemMeta())
|
||||
setData(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() >= item.getItemMeta().getPersistentDataContainer().get(ts, PersistentDataType.LONG)) {
|
||||
setData(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
fListener.getLog().append2(Msg.StaffMsgDropperExploit.getValue(block.getLocation().toString()));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private void setData(ItemStack item) {
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
PersistentDataContainer data = meta.getPersistentDataContainer();
|
||||
NamespacedKey ts = new NamespacedKey(IllegalStack.getPlugin(), "timeStamp");
|
||||
meta.getPersistentDataContainer().set(ts, PersistentDataType.LONG, System.currentTimeMillis() + 2500l);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
* package main.java.me.dniym.utils;
|
||||
*
|
||||
* public class DropExploit { private static final HashSet<DropExploit>
|
||||
* trackedBlocks = new HashSet<>(); private final Block block; private final
|
||||
* HashMap<ItemStack, Long> items = new HashMap<>(); private final int id = 0;
|
||||
*
|
||||
* public DropExploit(Block block) { this.block = block;
|
||||
* trackedBlocks.add(this); }
|
||||
*
|
||||
* public static DropExploit findBlock(Block block) {
|
||||
*
|
||||
* for (DropExploit de : trackedBlocks) if (de.block.equals(block)) return de;
|
||||
* return new DropExploit(block); }
|
||||
*
|
||||
* public boolean tick(ItemStack item) { NBTItem nbti = new NBTItem(item);
|
||||
*
|
||||
* //if( !nbti.hasKey("TimeStamp")) { if (nbti.getLong("TimeStamp") == null ||
|
||||
* nbti.getLong("TimeStamp") == 0) { nbti.setLong("TimeStamp",
|
||||
* System.currentTimeMillis() + 2500L); return false; }
|
||||
*
|
||||
* if (System.currentTimeMillis() >= nbti.getLong("TimeStamp")) {
|
||||
* nbti.setLong("TimeStamp", System.currentTimeMillis() + 2500L); return false;
|
||||
* } fListener.getLog().append2(Msg.StaffMsgDropperExploit.getValue(block.
|
||||
* getLocation().toString())); return true; }
|
||||
*
|
||||
* public boolean tick(ItemStack item) {
|
||||
*
|
||||
* NamespacedKey ts = new NamespacedKey(IllegalStack.getPlugin(), "timeStamp");
|
||||
*
|
||||
* if (!item.hasItemMeta() ||
|
||||
* !item.getItemMeta().getPersistentDataContainer().has(ts,
|
||||
* PersistentDataType.LONG)) { if (item.hasItemMeta()) setData(item); return
|
||||
* false; }
|
||||
*
|
||||
* if (System.currentTimeMillis() >=
|
||||
* item.getItemMeta().getPersistentDataContainer().get(ts,
|
||||
* PersistentDataType.LONG)) { setData(item); return false; }
|
||||
*
|
||||
*
|
||||
* fListener.getLog().append2(Msg.StaffMsgDropperExploit.getValue(block.
|
||||
* getLocation().toString())); return true;
|
||||
*
|
||||
* }
|
||||
*
|
||||
* private void setData(ItemStack item) {
|
||||
*
|
||||
* ItemMeta meta = item.getItemMeta(); PersistentDataContainer data =
|
||||
* meta.getPersistentDataContainer(); NamespacedKey ts = new
|
||||
* NamespacedKey(IllegalStack.getPlugin(), "timeStamp");
|
||||
* meta.getPersistentDataContainer().set(ts, PersistentDataType.LONG,
|
||||
* System.currentTimeMillis() + 2500l); item.setItemMeta(meta);
|
||||
*
|
||||
* }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
@@ -26,29 +26,38 @@ public class GuiObject implements InventoryHolder, Listener {
|
||||
private final Inventory inv;
|
||||
|
||||
public GuiObject() {
|
||||
// Create a new inventory, with "this" owner for comparison with other inventories, a size of nine, called
|
||||
|
||||
// Create a new inventory, with "this" owner for comparison with other
|
||||
// inventories, a size of nine, called
|
||||
// example
|
||||
inv = Bukkit.createInventory(this, 9, "Example");
|
||||
|
||||
// Put the items into the inventory
|
||||
initializeItems();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
|
||||
return inv;
|
||||
|
||||
}
|
||||
|
||||
// You can call this whenever you want to put the items in or use your existing gui code
|
||||
// You can call this whenever you want to put the items in or use your existing
|
||||
// gui code
|
||||
public void initializeItems() {
|
||||
inv.addItem(createGuiItem(
|
||||
Material.DIAMOND_SWORD, "Example Sword", "�aFirst line of the lore", "�bSecond line of the lore"));
|
||||
inv.addItem(createGuiItem(
|
||||
Material.IRON_HELMET, "�bExample Helmet", "�aFirst line of the lore", "�bSecond line of the lore"));
|
||||
|
||||
inv.addItem(createGuiItem(Material.DIAMOND_SWORD, "Example Sword", "�aFirst line of the lore",
|
||||
"�bSecond line of the lore"));
|
||||
inv.addItem(createGuiItem(Material.IRON_HELMET, "�bExample Helmet", "�aFirst line of the lore",
|
||||
"�bSecond line of the lore"));
|
||||
|
||||
}
|
||||
|
||||
// Nice little method to create a gui item with a custom name, and description
|
||||
protected ItemStack createGuiItem(final Material material, final String name, final String... lore) {
|
||||
|
||||
final ItemStack item = new ItemStack(material, 1);
|
||||
final ItemMeta meta = item.getItemMeta();
|
||||
|
||||
@@ -58,31 +67,44 @@ public class GuiObject implements InventoryHolder, Listener {
|
||||
meta.setLore(Arrays.asList(lore));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
// You can open the inventory with this
|
||||
public void openInventory(final HumanEntity ent) {
|
||||
|
||||
ent.openInventory(inv);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Highly recommend using this method as you can easily identify YOUR custom inventory object by simply doing
|
||||
* if (inventory.getHolder() instanceof GuiObject)
|
||||
* Highly recommend using this method as you can easily identify YOUR custom
|
||||
* inventory object by simply doing if (inventory.getHolder() instanceof
|
||||
* GuiObject)
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(final InventoryClickEvent e) {
|
||||
|
||||
if (e.getInventory().getHolder() != this) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
final ItemStack clickedItem = e.getCurrentItem();
|
||||
// verify current item is not null
|
||||
if (clickedItem == null || clickedItem.getType() == Material.AIR) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final Player p = (Player) e.getWhoClicked();
|
||||
// Using slots click is a best option for your inventory click's
|
||||
p.sendMessage("You clicked at slot " + e.getRawSlot());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,18 +12,26 @@ public class MagicHook {
|
||||
public static boolean isMagicItem(ItemStack is) {
|
||||
|
||||
if (magicApi == null) {
|
||||
|
||||
getApi();
|
||||
|
||||
}
|
||||
|
||||
return magicApi.isBrush(is) || magicApi.isSpell(is) || magicApi.isUpgrade(is) || magicApi.isWand(is);
|
||||
|
||||
}
|
||||
|
||||
private static void getApi() {
|
||||
|
||||
Plugin magicPlugin = Bukkit.getPluginManager().getPlugin("Magic");
|
||||
if (!(magicPlugin instanceof MagicAPI)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
magicApi = ((MagicAPI) magicPlugin);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,36 +22,52 @@ public class NBTApiStuff {
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + NBTApiStuff.class.getSimpleName());
|
||||
|
||||
public static ItemStack checkTimestampLegacy(ItemStack item) {
|
||||
|
||||
// Old backwards compatible version
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
|
||||
if (System.currentTimeMillis() >= nbti.getLong("TimeStamp")) {
|
||||
|
||||
nbti.removeKey("TimeStamp");
|
||||
nbti.setLong("TimeStamp", System.currentTimeMillis() + 4500L);
|
||||
|
||||
} else {
|
||||
|
||||
// looped item?
|
||||
return null; // return null if the item is looping
|
||||
|
||||
}
|
||||
|
||||
return nbti.getItem(); // return the item with an updated timestamp.
|
||||
|
||||
}
|
||||
|
||||
public static ItemStack addNBTTagLegacy(ItemStack item, String value) {
|
||||
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
if (!nbti.hasKey(value)) {
|
||||
|
||||
nbti.setString(value, value);
|
||||
return nbti.getItem();
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static ItemStack updateTimeStampLegacy(ItemStack item) {
|
||||
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
if (!nbti.hasKey("TimeStamp")) {
|
||||
|
||||
nbti.setLong("TimeStamp", (System.currentTimeMillis() + 4500L));
|
||||
return nbti.getItem();
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static void getEntityTags(Entity ent) {
|
||||
@@ -66,10 +82,13 @@ public class NBTApiStuff {
|
||||
for (NBTListCompound s : nbtent.getCompound("Offers").getCompoundList("Recipes")) {
|
||||
|
||||
if (s.getInteger("specialPrice") < -8) {
|
||||
|
||||
LOGGER.info("Old Price: {}", s.getInteger("specialPrice"));
|
||||
s.setInteger("specialPrice", -8);
|
||||
LOGGER.info("Updated Price: {}", s.getInteger("specialPrice"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// for(NBTListCompound s:nbtent.getCompoundList("Gossips"))
|
||||
@@ -77,137 +96,180 @@ public class NBTApiStuff {
|
||||
}
|
||||
|
||||
public static boolean hasNbtTagLegacy(ItemStack item, String tag) {
|
||||
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
return nbti.hasKey(tag);
|
||||
|
||||
}
|
||||
|
||||
public static int isBadShulkerLegacy(ItemStack is) {
|
||||
/*
|
||||
NBTItem nbti2 = new NBTItem(is);
|
||||
for(String key:nbti2.getKeys())
|
||||
{
|
||||
|
||||
NBTCompoundList nbtList = nbti2.getCompoundList(key);
|
||||
|
||||
if(nbti2.getType(key) == NBTType.NBTTagList)
|
||||
{
|
||||
NBTTagList nestedList = nbti2.getObject(key, NBTTagList.class);
|
||||
if(nestedList != null) {
|
||||
|
||||
} else {
|
||||
nbti2.removeKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
* NBTItem nbti2 = new NBTItem(is); for(String key:nbti2.getKeys()) {
|
||||
*
|
||||
* NBTCompoundList nbtList = nbti2.getCompoundList(key);
|
||||
*
|
||||
* if(nbti2.getType(key) == NBTType.NBTTagList) { NBTTagList nestedList =
|
||||
* nbti2.getObject(key, NBTTagList.class); if(nestedList != null) {
|
||||
*
|
||||
* } else { nbti2.removeKey(key); } } }
|
||||
*/
|
||||
|
||||
if (is.getType().name().contains("SHULKER_BOX")) {
|
||||
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
NBTCompound tag = nbti.getCompound("BlockEntityTag");
|
||||
if (tag == null) {
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
NBTCompoundList itemTag = tag.getCompoundList("Items");
|
||||
if (itemTag == null) {
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
if (itemTag.size() > 27) {
|
||||
|
||||
return itemTag.size();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static void hasBadCustomDataOnArmorLegacy(Player p) {
|
||||
|
||||
ItemStack is = p.getInventory().getHelmet();
|
||||
String slot = "";
|
||||
if (hasBadCustomDataLegacy(p.getInventory().getBoots())) {
|
||||
|
||||
slot = "boots";
|
||||
p.getInventory().setBoots(new ItemStack(Material.AIR));
|
||||
|
||||
} else if (hasBadCustomDataLegacy(p.getInventory().getChestplate())) {
|
||||
|
||||
slot = "chestplate";
|
||||
p.getInventory().setChestplate(new ItemStack(Material.AIR));
|
||||
|
||||
} else if (hasBadCustomDataLegacy(p.getInventory().getHelmet())) {
|
||||
|
||||
p.getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||
slot = "helmet";
|
||||
|
||||
} else if (hasBadCustomDataLegacy(p.getInventory().getLeggings())) {
|
||||
|
||||
p.getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||
slot = "leggings";
|
||||
|
||||
}
|
||||
|
||||
if (!slot.isEmpty()) {
|
||||
|
||||
fListener.getLog().append2(Msg.CustomAttribsRemoved2.getValue(p, is, slot));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasBadCustomDataLegacy(ItemStack is) {
|
||||
|
||||
if (is == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
NBTCompoundList itemTag = nbti.getCompoundList("AttributeModifiers");
|
||||
|
||||
return (itemTag != null && itemTag.size() > 0);
|
||||
|
||||
}
|
||||
|
||||
public static boolean checkForBadCustomDataLegacy(ItemStack is, Object obj) {
|
||||
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
NBTCompoundList itemTag = nbti.getCompoundList("AttributeModifiers");
|
||||
if (itemTag == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (itemTag.size() > 0) {
|
||||
|
||||
itemTag.clear();
|
||||
nbti.setObject("AttributeModifiers", itemTag);
|
||||
|
||||
StringBuilder attribs = new StringBuilder();
|
||||
attribs.append("Custom Attribute Data");
|
||||
fListener
|
||||
.getLog()
|
||||
.append(Msg.CustomAttribsRemoved3.getValue(is, obj, attribs), Protections.RemoveCustomAttributes);
|
||||
fListener.getLog().append(Msg.CustomAttribsRemoved3.getValue(is, obj, attribs),
|
||||
Protections.RemoveCustomAttributes);
|
||||
|
||||
if (obj instanceof Player) {
|
||||
|
||||
((Player) obj).getInventory().remove(is);
|
||||
|
||||
} else {
|
||||
|
||||
LOGGER.error(
|
||||
"The object type: {} is not accounted for in the legacy NBT Api check.. Please report this to dNiym at the IllegalStack discord or via spigot!",
|
||||
obj.toString());
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static void checkForBadCustomDataLegacy(ItemStack is, Player p, boolean sendToPlayer) {
|
||||
|
||||
boolean helmet = false;
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
NBTCompoundList itemTag = nbti.getCompoundList("AttributeModifiers");
|
||||
if (itemTag == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (itemTag.size() > 0) {
|
||||
|
||||
itemTag.clear();
|
||||
nbti.setObject("AttributeModifiers", itemTag);
|
||||
|
||||
if (sendToPlayer) {
|
||||
|
||||
p.sendMessage(Msg.CustomAttribsRemoved.getValue(p, is, "Custom Attribute Data"));
|
||||
|
||||
} else {
|
||||
|
||||
fListener.getLog().append2(Msg.CustomAttribsRemoved.getValue(p, is, "Custom Attribute Data"));
|
||||
|
||||
}
|
||||
|
||||
p.getInventory().remove(is);
|
||||
|
||||
// p.getInventory().addItem(nbti.getItem());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void isProCosmeticsLegacy(ItemStack is) {
|
||||
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
nbti.hasKey("PROCOSMETICS");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ public class NBTStuff {
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + NBTStuff.class.getSimpleName());
|
||||
|
||||
public static ItemStack addNBTTag(ItemStack item, String value, Protections prot) {
|
||||
|
||||
if (hasSpigotNBT() && item.hasItemMeta()) {
|
||||
|
||||
ItemMeta im = item.getItemMeta();
|
||||
@@ -37,14 +38,21 @@ public class NBTStuff {
|
||||
item.setItemMeta(im);
|
||||
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
|
||||
item = NBTApiStuff.addNBTTagLegacy(item, value);
|
||||
|
||||
} else {
|
||||
|
||||
Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
|
||||
}
|
||||
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
public static ItemStack updateTimeStamp(ItemStack item, Protections prot) {
|
||||
|
||||
if (hasSpigotNBT() && item.hasItemMeta()) {
|
||||
// use the new built in methods.
|
||||
|
||||
@@ -53,103 +61,157 @@ public class NBTStuff {
|
||||
PersistentDataContainer data = im.getPersistentDataContainer();
|
||||
NamespacedKey key = new NamespacedKey(IllegalStack.getPlugin(), "timestamp");
|
||||
if (data.has(key, PersistentDataType.LONG)) {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
data.set(key, PersistentDataType.LONG, (System.currentTimeMillis() + 4500L));
|
||||
item.setItemMeta(im);
|
||||
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
|
||||
item = NBTApiStuff.updateTimeStampLegacy(item);
|
||||
|
||||
} else {
|
||||
|
||||
Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
|
||||
}
|
||||
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
public static ItemStack checkTimestamp(ItemStack item, Protections prot) {
|
||||
|
||||
if (hasSpigotNBT()) {
|
||||
|
||||
// use the new built in methods.
|
||||
if (item.hasItemMeta()) {
|
||||
|
||||
ItemMeta im = item.getItemMeta();
|
||||
|
||||
PersistentDataContainer data = im.getPersistentDataContainer();
|
||||
NamespacedKey key = new NamespacedKey(IllegalStack.getPlugin(), "timestamp");
|
||||
if (data.has(key, PersistentDataType.LONG)) {
|
||||
|
||||
Long Timestamp = data.get(key, PersistentDataType.LONG);
|
||||
if (System.currentTimeMillis() >= Timestamp) { // timestamp expired reset it
|
||||
|
||||
data.set(key, PersistentDataType.LONG, System.currentTimeMillis() + 4500L);
|
||||
item.setItemMeta(im);
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
|
||||
item = NBTApiStuff.checkTimestampLegacy(item);
|
||||
|
||||
} else {
|
||||
|
||||
Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
|
||||
}
|
||||
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasSpigotNBT() {
|
||||
|
||||
return fListener.getInstance().is115() || fListener.getInstance().is114();
|
||||
|
||||
}
|
||||
|
||||
public static boolean isProCosmetics(ItemStack is, Protections prot) {
|
||||
|
||||
if (IllegalStack.getProCosmetics() != null) {
|
||||
|
||||
if (IllegalStack.isNbtAPI()) {
|
||||
|
||||
NBTApiStuff.isProCosmeticsLegacy(is);
|
||||
|
||||
} else {
|
||||
|
||||
Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static Boolean hasNbtTag(String pluginName, ItemStack item, String tag, Protections prot) {
|
||||
|
||||
if (item == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginName);
|
||||
if (plugin == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (hasSpigotNBT()) {
|
||||
|
||||
if (item.hasItemMeta()) {
|
||||
|
||||
ItemMeta im = item.getItemMeta();
|
||||
|
||||
PersistentDataContainer data = im.getPersistentDataContainer();
|
||||
NamespacedKey key = new NamespacedKey(plugin, tag);
|
||||
return data.has(key, PersistentDataType.STRING);
|
||||
|
||||
}
|
||||
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
|
||||
return NBTApiStuff.hasNbtTagLegacy(item, tag);
|
||||
|
||||
} else {
|
||||
|
||||
Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static int isBadShulker(ItemStack is) {
|
||||
|
||||
if (!IllegalStack.isNbtAPI() && Protections.DestroyInvalidShulkers.isEnabled()) {
|
||||
|
||||
Protections.DestroyInvalidShulkers.setEnabled(false);
|
||||
LOGGER.error(
|
||||
"Protection DestroyInvalidShulkers was enabled, however NBTAPI 2.0+ was not loaded on this server, this protection will only work if NBTAPI is present and running. This protection has automatically been disabled. ");
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
if (!Protections.DestroyInvalidShulkers.isEnabled()) {
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
return NBTApiStuff.isBadShulkerLegacy(is);
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasBadCustomData(ItemStack is) {
|
||||
@@ -159,95 +221,134 @@ public class NBTStuff {
|
||||
if (IllegalStack.isHasAttribAPI() && is.hasItemMeta() && im.hasAttributeModifiers()) {
|
||||
|
||||
return true;
|
||||
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
|
||||
return NBTApiStuff.hasBadCustomDataLegacy(is);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static void checkForNegativeDurability(ItemStack is, Player p) {
|
||||
|
||||
if (is == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (IllegalStack.isHasAttribAPI()) {
|
||||
|
||||
if (is.hasItemMeta() && is.getItemMeta() instanceof Damageable) {
|
||||
|
||||
Damageable dmg = (Damageable) is.getItemMeta();
|
||||
if (dmg.getDamage() > is.getType().getMaxDurability()) {
|
||||
fListener
|
||||
.getLog()
|
||||
.append(Msg.IllegalStackDurability.getValue(p, is), Protections.FixNegativeDurability);
|
||||
|
||||
fListener.getLog().append(Msg.IllegalStackDurability.getValue(p, is),
|
||||
Protections.FixNegativeDurability);
|
||||
dmg.setDamage(is.getType().getMaxDurability());
|
||||
is.setItemMeta((ItemMeta) dmg);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void checkForBadCustomData(ItemStack is, Player p, boolean sendToPlayer) {
|
||||
|
||||
if (!is.hasItemMeta()) return;
|
||||
if (!is.hasItemMeta())
|
||||
return;
|
||||
|
||||
ItemMeta im = is.getItemMeta();
|
||||
|
||||
if (IllegalStack.isHasAttribAPI() && im.hasAttributeModifiers()) {
|
||||
|
||||
StringBuilder attribs = new StringBuilder();
|
||||
HashSet<Attribute> toRemove = new HashSet<>();
|
||||
for (Attribute a : im.getAttributeModifiers().keySet()) {
|
||||
|
||||
for (AttributeModifier st : im.getAttributeModifiers(a)) {
|
||||
|
||||
attribs.append(" ").append(st.getName()).append(" value: ").append(st.getAmount());
|
||||
|
||||
}
|
||||
|
||||
toRemove.add(a);
|
||||
|
||||
}
|
||||
|
||||
if (sendToPlayer) {
|
||||
|
||||
p.sendMessage(Msg.CustomAttribsRemoved.getValue(p, is, attribs.toString()));
|
||||
|
||||
} else {
|
||||
fListener
|
||||
.getLog()
|
||||
.append(
|
||||
Msg.CustomAttribsRemoved.getValue(p, is, attribs.toString()),
|
||||
Protections.RemoveCustomAttributes);
|
||||
|
||||
fListener.getLog().append(Msg.CustomAttribsRemoved.getValue(p, is, attribs.toString()),
|
||||
Protections.RemoveCustomAttributes);
|
||||
|
||||
}
|
||||
|
||||
for (Attribute remove : toRemove) {
|
||||
|
||||
im.removeAttributeModifier(remove);
|
||||
|
||||
}
|
||||
|
||||
for (ItemFlag iFlag : im.getItemFlags()) {
|
||||
|
||||
im.removeItemFlags(iFlag);
|
||||
|
||||
}
|
||||
|
||||
is.setItemMeta(im);
|
||||
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
|
||||
NBTApiStuff.hasBadCustomDataOnArmorLegacy(p);
|
||||
NBTApiStuff.checkForBadCustomDataLegacy(is, p, sendToPlayer);
|
||||
|
||||
} else {
|
||||
|
||||
Msg.StaffNoNBTAPI.getValue(Protections.RemoveCustomAttributes.name());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// should only ever be used on 1.15+ servers no need for legacy
|
||||
public static void addNBTTag(Entity entity, String value) {
|
||||
|
||||
if (hasSpigotNBT()) {
|
||||
|
||||
PersistentDataContainer data = entity.getPersistentDataContainer();
|
||||
NamespacedKey key = new NamespacedKey(IllegalStack.getPlugin(), value);
|
||||
|
||||
data.set(key, PersistentDataType.STRING, value);
|
||||
entity.getPersistentDataContainer().set(key, PersistentDataType.STRING, value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// should only ever be used on 1.15+ servers no need for legacy
|
||||
public static boolean hasNbtTag(Entity entity, String tag) {
|
||||
|
||||
if (entity == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
PersistentDataContainer data = entity.getPersistentDataContainer();
|
||||
NamespacedKey key = new NamespacedKey(IllegalStack.getPlugin(), tag);
|
||||
return data.has(key, PersistentDataType.STRING);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,64 +21,91 @@ public class PacketAttack {
|
||||
private final HashMap<String, Integer> pAttack = new HashMap<>();
|
||||
|
||||
public PacketAttack(UUID uniqueId) {
|
||||
|
||||
playerid = uniqueId;
|
||||
attacks.add(this);
|
||||
|
||||
}
|
||||
|
||||
public static PacketAttack findPlayer(UUID uniqueId) {
|
||||
|
||||
for (PacketAttack pa : attacks) {
|
||||
|
||||
if (pa.playerid.equals(uniqueId)) {
|
||||
|
||||
return pa;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new PacketAttack(uniqueId);
|
||||
|
||||
}
|
||||
|
||||
public boolean addAttempt(Object packetEvent, String attackType) {
|
||||
|
||||
if (!this.pAttack.containsKey(attackType)) {
|
||||
|
||||
this.pAttack.put(attackType, 0);
|
||||
|
||||
}
|
||||
|
||||
this.pAttack.put(attackType, this.pAttack.get(attackType) + 1);
|
||||
int maxAttempts = 250;
|
||||
|
||||
if (attackType.equalsIgnoreCase("WINDOW_INVALID_CLICK")) {
|
||||
|
||||
maxAttempts = 5;
|
||||
|
||||
}
|
||||
|
||||
if (attackType.equalsIgnoreCase("WINDOW_CLICK_SPAM")) {
|
||||
|
||||
maxAttempts = 80;
|
||||
|
||||
}
|
||||
|
||||
return shouldCancelPacket(packetEvent, maxAttempts, attackType);
|
||||
|
||||
}
|
||||
|
||||
public boolean shouldCancelPacket(Object packetEvent, int maxAttempts, String attackType) {
|
||||
|
||||
if (packetEvent instanceof PacketEvent) {
|
||||
|
||||
PacketEvent event = (PacketEvent) packetEvent;
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
|
||||
int size = event.getPacket().getBytes().toString().length();
|
||||
|
||||
if (size > 2700) { // sending too large of a packet, cancel it regardless
|
||||
fListener
|
||||
.getLog()
|
||||
.append2(
|
||||
"Player sent a packet too large for the server to handle! Probably a packet attack!");
|
||||
|
||||
fListener.getLog().append2(
|
||||
"Player sent a packet too large for the server to handle! Probably a packet attack!");
|
||||
event.getPlayer().kickPlayer("Invalid Packet Detected (packet too large)");
|
||||
return true;
|
||||
|
||||
} else if (maxAttempts > 0) {
|
||||
|
||||
if (this.pAttack.get(attackType) >= maxAttempts) {
|
||||
|
||||
// player has sent too many invalid packets of a given type.
|
||||
LOGGER.info("Player sent too many bad packets of type: {} kicking them.", attackType);
|
||||
event.getPlayer().kickPlayer("Too many bad packets detected! " + attackType);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,196 +35,334 @@ public class Scheduler {
|
||||
public static final boolean FOLIA;
|
||||
|
||||
static {
|
||||
|
||||
boolean folia;
|
||||
try {
|
||||
|
||||
Class.forName("io.papermc.paper.threadedregions.scheduler.AsyncScheduler");
|
||||
folia = true;
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
folia = false;
|
||||
|
||||
}
|
||||
|
||||
FOLIA = folia;
|
||||
|
||||
}
|
||||
|
||||
public static void executeOrScheduleSync(Plugin plugin, Runnable task, Entity entity) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
if (Bukkit.isOwnedByCurrentRegion(entity)) {
|
||||
|
||||
task.run();
|
||||
|
||||
} else {
|
||||
|
||||
entity.getScheduler().run(plugin, st -> task.run(), null);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
|
||||
task.run();
|
||||
|
||||
} else {
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, task);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static <T> Future<T> executeOrScheduleSync(Plugin plugin, Supplier<T> task, Entity entity) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
if (Bukkit.isOwnedByCurrentRegion(entity)) {
|
||||
|
||||
return CompletableFuture.completedFuture(task.get());
|
||||
|
||||
} else {
|
||||
|
||||
CompletableFuture<T> future = new CompletableFuture<>();
|
||||
entity.getScheduler()
|
||||
.run(
|
||||
plugin,
|
||||
st -> {
|
||||
if (!future.isCancelled()) {
|
||||
future.complete(task.get());
|
||||
}
|
||||
},
|
||||
null);
|
||||
entity.getScheduler().run(plugin, st -> {
|
||||
|
||||
if (!future.isCancelled()) {
|
||||
|
||||
future.complete(task.get());
|
||||
|
||||
}
|
||||
|
||||
}, null);
|
||||
return future;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
|
||||
return CompletableFuture.completedFuture(task.get());
|
||||
|
||||
} else {
|
||||
|
||||
return Bukkit.getScheduler().callSyncMethod(plugin, task::get);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static <T> Future<T> executeOrScheduleSync(Plugin plugin, Supplier<T> task, Location location) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
if (Bukkit.isOwnedByCurrentRegion(location)) {
|
||||
|
||||
return CompletableFuture.completedFuture(task.get());
|
||||
|
||||
} else {
|
||||
|
||||
CompletableFuture<T> future = new CompletableFuture<>();
|
||||
Bukkit.getRegionScheduler().execute(plugin, location, () -> {
|
||||
|
||||
if (!future.isCancelled()) {
|
||||
|
||||
future.complete(task.get());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
return future;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
|
||||
return CompletableFuture.completedFuture(task.get());
|
||||
|
||||
} else {
|
||||
|
||||
return Bukkit.getScheduler().callSyncMethod(plugin, task::get);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void executeOrScheduleSync(Plugin plugin, Runnable task, Location location) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
if (Bukkit.isOwnedByCurrentRegion(location)) {
|
||||
|
||||
task.run();
|
||||
|
||||
} else {
|
||||
|
||||
Bukkit.getRegionScheduler().execute(plugin, location, task);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
|
||||
task.run();
|
||||
|
||||
} else {
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, task);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTask(Plugin plugin, Runnable task, Entity entity) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return new ScheduledTask(entity.getScheduler().run(plugin, st -> task.run(), null));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTask(plugin, task));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTaskLater(Plugin plugin, Runnable task, long delay, Entity entity) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return new ScheduledTask(entity.getScheduler().runDelayed(plugin, st -> task.run(), null, delay));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTaskLater(plugin, task, delay));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTaskTimer(Plugin plugin, Runnable task, long delay, long period, Entity entity) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return new ScheduledTask(
|
||||
entity.getScheduler().runAtFixedRate(plugin, st -> task.run(), null, Math.max(1, delay), period));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTaskTimer(plugin, task, delay, period));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTask(Plugin plugin, Runnable task, Location location) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return new ScheduledTask(Bukkit.getRegionScheduler().run(plugin, location, st -> task.run()));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTask(plugin, task));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTaskLater(Plugin plugin, Runnable task, long delay, Location location) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return new ScheduledTask(Bukkit.getRegionScheduler().runDelayed(plugin, location, st -> task.run(), delay));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTaskLater(plugin, task, delay));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTaskTimer(Plugin plugin, Runnable task, long delay, long period, Location location) {
|
||||
|
||||
if (FOLIA) {
|
||||
return new ScheduledTask(Bukkit.getRegionScheduler()
|
||||
.runAtFixedRate(plugin, location, st -> task.run(), Math.max(1, delay), period));
|
||||
|
||||
return new ScheduledTask(Bukkit.getRegionScheduler().runAtFixedRate(plugin, location, st -> task.run(),
|
||||
Math.max(1, delay), period));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTaskTimer(plugin, task, delay, period));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTask(Plugin plugin, Runnable task) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return new ScheduledTask(Bukkit.getGlobalRegionScheduler().run(plugin, st -> task.run()));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTask(plugin, task));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTaskLater(Plugin plugin, Runnable task, long delay) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return new ScheduledTask(Bukkit.getGlobalRegionScheduler().runDelayed(plugin, st -> task.run(), delay));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTaskLater(plugin, task, delay));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTaskTimer(Plugin plugin, Runnable task, long delay, long period) {
|
||||
|
||||
if (FOLIA) {
|
||||
return new ScheduledTask(Bukkit.getGlobalRegionScheduler()
|
||||
.runAtFixedRate(plugin, st -> task.run(), Math.max(1, delay), period));
|
||||
|
||||
return new ScheduledTask(Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, st -> task.run(),
|
||||
Math.max(1, delay), period));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTaskTimer(plugin, task, delay, period));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTaskAsynchronously(Plugin plugin, Runnable task) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return new ScheduledTask(Bukkit.getAsyncScheduler().runNow(plugin, st -> task.run()));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTaskAsynchronously(plugin, task));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTaskLaterAsynchronously(Plugin plugin, Runnable task, long delay) {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return new ScheduledTask(
|
||||
Bukkit.getAsyncScheduler().runDelayed(plugin, st -> task.run(), delay * 50, TimeUnit.MILLISECONDS));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, task, delay));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static ScheduledTask runTaskTimerAsynchronously(Plugin plugin, Runnable task, long delay, long period) {
|
||||
|
||||
if (FOLIA) {
|
||||
return new ScheduledTask(Bukkit.getAsyncScheduler()
|
||||
.runAtFixedRate(
|
||||
plugin, st -> task.run(), Math.max(1, delay * 50), period * 50, TimeUnit.MILLISECONDS));
|
||||
|
||||
return new ScheduledTask(Bukkit.getAsyncScheduler().runAtFixedRate(plugin, st -> task.run(),
|
||||
Math.max(1, delay * 50), period * 50, TimeUnit.MILLISECONDS));
|
||||
|
||||
} else {
|
||||
|
||||
return new ScheduledTask(Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, task, delay, period));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ScheduledTask {
|
||||
@@ -232,31 +370,53 @@ public class Scheduler {
|
||||
private final Object task;
|
||||
|
||||
public ScheduledTask(Object task) {
|
||||
|
||||
this.task = task;
|
||||
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return ((io.papermc.paper.threadedregions.scheduler.ScheduledTask) task).isCancelled();
|
||||
|
||||
} else {
|
||||
|
||||
return ((BukkitTask) task).isCancelled();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
((io.papermc.paper.threadedregions.scheduler.ScheduledTask) task).cancel();
|
||||
|
||||
} else {
|
||||
|
||||
((BukkitTask) task).cancel();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Plugin getOwner() {
|
||||
|
||||
if (FOLIA) {
|
||||
|
||||
return ((io.papermc.paper.threadedregions.scheduler.ScheduledTask) task).getOwningPlugin();
|
||||
|
||||
} else {
|
||||
|
||||
return ((BukkitTask) task).getOwner();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,35 +10,54 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class SlimefunCompat {
|
||||
|
||||
public static boolean isValid(Inventory inv) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isValid(ItemStack is, Enchantment en) {
|
||||
|
||||
if (is == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (IllegalStack.isSlimeFun()) {
|
||||
|
||||
SlimefunItem sfi = SlimefunItem.getByItem(is);
|
||||
if (sfi != null) {
|
||||
|
||||
ItemStack sfiBase = sfi.getItem();
|
||||
// base Slimefun item does not have this enchantment.
|
||||
return sfiBase.containsEnchantment(en);
|
||||
|
||||
// otherwise it is a slimefun item and it does contain the enchantment.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (IllegalStack.isClueScrolls() && IllegalStack.isNbtAPI()) {
|
||||
|
||||
if (is.hasItemMeta()) {
|
||||
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
for (String key : nbti.getKeys()) {
|
||||
|
||||
if (key.contains("ClueScrolls")) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,62 +16,78 @@ public class SpigotMethods {
|
||||
|
||||
String sTag = " ";
|
||||
if (!protections.isList()) {
|
||||
|
||||
sTag = ChatColor.DARK_AQUA + "[" + status + ChatColor.DARK_AQUA + "]";
|
||||
|
||||
}
|
||||
|
||||
TextComponent cLink = new TextComponent(sTag);
|
||||
if (!protections.isList()) {
|
||||
|
||||
cLink.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/istack toggle " + protections.name()));
|
||||
cLink.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Toggle This Protection On/Off").create()));
|
||||
cLink.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Toggle This Protection On/Off").create()));
|
||||
|
||||
} else {
|
||||
|
||||
cLink = new TextComponent(ChatColor.GRAY + "[" + ChatColor.GREEN + "A");
|
||||
String cmd = "/istack value add " + protections.name();
|
||||
cLink.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd));
|
||||
cLink.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Add a value to this list").create()));
|
||||
cLink.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Add a value to this list").create()));
|
||||
TextComponent opt;
|
||||
|
||||
if (!protections.getTxtSet().isEmpty()) {
|
||||
|
||||
opt = new TextComponent(ChatColor.RED + "R");
|
||||
cmd = "/istack value remove " + protections.name();
|
||||
opt.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd));
|
||||
opt.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Remove a value from this list").create()));
|
||||
opt.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Remove a value from this list").create()));
|
||||
|
||||
cLink.addExtra(opt);
|
||||
|
||||
} else {
|
||||
|
||||
cLink.addExtra(" ");
|
||||
|
||||
}
|
||||
|
||||
opt = new TextComponent(ChatColor.AQUA + "L");
|
||||
opt.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
opt.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(ChatColor.AQUA + protections.findValue()).create()));
|
||||
|
||||
cLink.addExtra(opt);
|
||||
cLink.addExtra(ChatColor.GRAY + "] ");
|
||||
|
||||
}
|
||||
|
||||
cLink.addExtra(ChatColor.GOLD + " " + protections.getDisplayName());
|
||||
TextComponent info = new TextComponent(ChatColor.GREEN + " *");
|
||||
if (!protections.getDescription().equalsIgnoreCase("")) {
|
||||
String desc =
|
||||
protections.getDescription() + ChatColor.AQUA + " " + protections.getVersion() + ChatColor.RESET;
|
||||
|
||||
String desc = protections.getDescription() + ChatColor.AQUA + " " + protections.getVersion()
|
||||
+ ChatColor.RESET;
|
||||
info.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(desc).create()));
|
||||
|
||||
}
|
||||
|
||||
cLink.addExtra(info);
|
||||
|
||||
// kids
|
||||
if (children) {
|
||||
|
||||
TextComponent opt = new TextComponent(ChatColor.YELLOW + "(more options)");
|
||||
opt.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND, "/istack prot " + catId + " " + protections.getProtId()));
|
||||
opt.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to show/hide more options").create()));
|
||||
opt.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/istack prot " + catId + " " + protections.getProtId()));
|
||||
opt.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Click to show/hide more options").create()));
|
||||
cLink.addExtra(opt);
|
||||
|
||||
}
|
||||
|
||||
return cLink;
|
||||
|
||||
}
|
||||
|
||||
public static BaseComponent makeCategoryText(String category, Boolean show, int catID) {
|
||||
@@ -80,26 +96,36 @@ public class SpigotMethods {
|
||||
String sText = ChatColor.GRAY + " (" + ChatColor.GREEN + "SHOW" + ChatColor.GRAY + ")";
|
||||
|
||||
if (show) {
|
||||
|
||||
sText = ChatColor.GRAY + " (" + ChatColor.RED + "HIDE" + ChatColor.GRAY + ")";
|
||||
|
||||
}
|
||||
|
||||
TextComponent option = new TextComponent(sText);
|
||||
option.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GRAY + "Click to activate").create()));
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(ChatColor.GRAY + "Click to activate").create()));
|
||||
|
||||
String command = "/istack prot ";
|
||||
if (!show) {
|
||||
|
||||
if (catID == 1) {
|
||||
|
||||
command = command + 1;
|
||||
|
||||
}
|
||||
|
||||
if (catID == 2) {
|
||||
|
||||
command = command + 2;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
|
||||
cLink.addExtra(option);
|
||||
return cLink;
|
||||
|
||||
}
|
||||
|
||||
public static BaseComponent makeChildText(Protections p, int catId) {
|
||||
@@ -109,29 +135,37 @@ public class SpigotMethods {
|
||||
cLink.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(p.getDescription())));
|
||||
|
||||
if (p.isList()) {
|
||||
|
||||
TextComponent option = new TextComponent(ChatColor.GOLD + " [" + ChatColor.GREEN + "A");
|
||||
if (p == Protections.EnchantedItemWhitelist) {
|
||||
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/istack enchantwhitelistmode"));
|
||||
option.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new Text("Click to toggle adding EnchantedItemWhitelist add mode on/off")));
|
||||
|
||||
} else {
|
||||
|
||||
option.setClickEvent(
|
||||
new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/istack value add " + p.name()));
|
||||
option.setHoverEvent(
|
||||
new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Click to add a value to this list.")));
|
||||
|
||||
}
|
||||
|
||||
cLink.addExtra(option);
|
||||
if (!p.getTxtSet().isEmpty()) {
|
||||
|
||||
option = new TextComponent(ChatColor.RED + "R");
|
||||
option.setClickEvent(
|
||||
new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/istack value remove " + p.name()));
|
||||
option.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT, new Text("Click to remove a value from this list.")));
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new Text("Click to remove a value from this list.")));
|
||||
cLink.addExtra(option);
|
||||
|
||||
} else {
|
||||
|
||||
cLink.addExtra(" ");
|
||||
|
||||
}
|
||||
|
||||
option = new TextComponent(ChatColor.GRAY + "L" + ChatColor.GOLD + "] ");
|
||||
@@ -142,14 +176,20 @@ public class SpigotMethods {
|
||||
|
||||
int val = 0;
|
||||
if (p.getConfigValue() instanceof Integer) {
|
||||
|
||||
val = (Integer) p.getConfigValue();
|
||||
|
||||
}
|
||||
|
||||
String pad = "";
|
||||
if (val <= 9) {
|
||||
|
||||
pad = " ";
|
||||
|
||||
} else if (val <= 99) {
|
||||
|
||||
pad = " ";
|
||||
|
||||
}
|
||||
|
||||
TextComponent option = new TextComponent(ChatColor.GRAY + " [" + p.findValue() + pad + "] ");
|
||||
@@ -160,20 +200,25 @@ public class SpigotMethods {
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command));
|
||||
|
||||
cLink.addExtra(option);
|
||||
|
||||
} else if (!p.getTxtValue().isEmpty()) {
|
||||
TextComponent option =
|
||||
new TextComponent(ChatColor.GRAY + " [" + ChatColor.GREEN + "TXT" + ChatColor.GRAY + "] ");
|
||||
|
||||
TextComponent option = new TextComponent(
|
||||
ChatColor.GRAY + " [" + ChatColor.GREEN + "TXT" + ChatColor.GRAY + "] ");
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(p.findValue())));
|
||||
option.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new Text(ChatColor.GRAY + p.findValue() + ChatColor.GREEN + " (Click to change)")));
|
||||
String command = "/istack value set " + p.name() + " " + p.getConfigValue();
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command));
|
||||
cLink.addExtra(option);
|
||||
|
||||
} else {
|
||||
|
||||
String status = ChatColor.GREEN + " ON";
|
||||
if (!p.isEnabled()) {
|
||||
|
||||
status = ChatColor.DARK_RED + "OFF";
|
||||
|
||||
}
|
||||
|
||||
TextComponent option = new TextComponent(ChatColor.GOLD + " [" + status + ChatColor.GOLD + "] ");
|
||||
@@ -181,6 +226,7 @@ public class SpigotMethods {
|
||||
String command = "/istack toggle " + p.name();
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command + " " + catId));
|
||||
cLink.addExtra(option);
|
||||
|
||||
}
|
||||
|
||||
cLink.addExtra(ChatColor.DARK_AQUA + p.getDisplayName());
|
||||
@@ -188,69 +234,104 @@ public class SpigotMethods {
|
||||
|
||||
String desc = p.getDescription();
|
||||
cLink.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(desc)));
|
||||
|
||||
}
|
||||
|
||||
return cLink;
|
||||
|
||||
}
|
||||
|
||||
public static String wordWrap(String text, int length) {
|
||||
|
||||
StringBuilder newString = new StringBuilder();
|
||||
if (text.length() <= length) {
|
||||
|
||||
return text;
|
||||
|
||||
}
|
||||
|
||||
String[] words = text.split(" ");
|
||||
|
||||
if (words.length == 0) {
|
||||
|
||||
newString = new StringBuilder(longWord(text, length));
|
||||
|
||||
}
|
||||
|
||||
if (words.length > 1) {
|
||||
|
||||
String temp1 = "";
|
||||
for (String word : words) {
|
||||
|
||||
if (temp1.length() > length) {
|
||||
|
||||
newString.append("\n").append(temp1);
|
||||
temp1 = word;
|
||||
|
||||
} else {
|
||||
|
||||
if (!temp1.equalsIgnoreCase("")) {
|
||||
|
||||
temp1 = temp1 + " " + word;
|
||||
|
||||
} else {
|
||||
|
||||
temp1 = word;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newString.append(" ").append(words[words.length - 1]);
|
||||
|
||||
}
|
||||
|
||||
return newString.toString();
|
||||
|
||||
}
|
||||
|
||||
public static String longWord(String text, int length) {
|
||||
|
||||
String[] words = text.split(" ");
|
||||
int counter = 0;
|
||||
StringBuilder newString = new StringBuilder();
|
||||
for (int i = 0; i < words[0].length(); i++) {
|
||||
|
||||
if (counter == length - 2) {
|
||||
|
||||
newString.append(words[0].charAt(i)).append("-\n");
|
||||
counter = 0;
|
||||
|
||||
} else {
|
||||
|
||||
newString.append(words[0].charAt(i));
|
||||
counter++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return newString.toString();
|
||||
|
||||
}
|
||||
|
||||
public static boolean isNPC(LivingEntity ent) {
|
||||
if (ent == null) return false;
|
||||
|
||||
if (ent == null)
|
||||
return false;
|
||||
|
||||
return ent.hasMetadata("shopkeeper") || ent.hasMetadata("NPC");
|
||||
|
||||
}
|
||||
|
||||
private static final class FlagFontInfo {
|
||||
|
||||
static int getPxLength(char c) {
|
||||
|
||||
switch (c) {
|
||||
|
||||
case 'i':
|
||||
case ':':
|
||||
return 1;
|
||||
@@ -264,11 +345,17 @@ public class SpigotMethods {
|
||||
return 4;
|
||||
default:
|
||||
return 5;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int getPxLength(String string) {
|
||||
|
||||
return string.chars().reduce(0, (p, i) -> p + getPxLength((char) i) + 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user